Page 1 of 1

REval v1.05x

Posted: Sun Sep 12, 2010 9:34 pm
by blueznl
Simple tool to verify regular expressions.

Screenshot, code and executable can be found here:

http://www.xs4all.nl/~bluez/purebasic/p ... tm#4_reval

Direct download:

http://www.xs4all.nl/~bluez/purebasic/reval.zip

Perhaps it might be a good idea to add a little 'quick reference' sheet to the purebasic docs? Something like this: (I've hidden it in the 'help' function of REval.)

Code: Select all

Quick Reference.
----------------

This text does not claim to be the complete (or correct) list of regular
expression components. It only provides a quick and dirty overview of 
some of all the (sometimes esoteric :-)) options.


Characters:

  a              - single character 'a'
  \t             - tab, chr(9)
  \r             - return, cr, chr(13)
  \n             - line feed, lf, chr(10)
  \e             - escape, esc, chr(27)
  \x09           - specific character in hexadecimal, \x09 is for example tab
  \u20AC         - unicade character, \u20AC is the euro currency sign

Special characters:

  \d             - digit ie. single character 0 to 9
  \w             - word character ie. single character a-z, A-Z, 0-9, underscore
  \s             - single 'whitespace' character ie. space, tab, line breaks
  .              - any single character

Classes:

  a class is a group of characters enclosed by square brackets, each character
  inside the brackets is a valid match, ranges can be specified by using '-'

  [a]            - single character 'a'
  [ab]           - single character, either 'a' or 'b'
  [^a]           - inside brackets! any single character except 'a'
  [0-9]          - single character 0 to 9
  [0-9A-F]       - single hexadecimal character
  c[ao]t         - matches 'cat' and 'cot' but not 'cit' or 'ct'

  inside classes you do not have to escape any metacharacters except ^ \ ] -

Metacharacters:

  [ \ ^ $ . | ? * + ( )

  several characters have a special meaning, you need to 'escape' them (preceed
  them with a backslash) if you want to use them literally

  cats|dogs      - matches 'cats' or 'dogs'
  cats\|dogs     - matches 'cats|dogs'
  colo?r         - matches 'color' and 'colour'
  colo\?r        - matches 'colo?r'

  inside square brackets (classes) the dash '-' needs escaping as well

  [1\-2]         - matches '1' '2' and '-'
  [1-2]          - matches '1' '2' but not '-'

Repetition / wildcards:

  .              - any single character except line breaks (see multiline flag)
  ?              - preceding condition zero or one time
  *              - zero up to many times
  +              - one up to many times
  {n}            - n times
  {n1,n2}        - minimal n1 times, maximal n2 times
  a?             - nothing or 'a'
  test{3}        - matches 'testtt'
  [0-9]{3}       - matches '000' '001' etc. all the way up to '999'
  (test){3}      - matches 'testtesttest'
  get(value)?    - matches 'get' as well as 'getvalue'

  remember that the wildcards * and + are 'greedy'

Grouping:

  ()             - groups a part of the expression
  (test){3}      - matches 'testtesttest'

Position:

  ^              - outside brackets! start of the string
  $              - end of string
  bob            - bob may exist anywhere in the string
  ^bob           - string must start with 'bob'
  bob$           - string must end with 'bob'
  ^bob$          - string must be 'bob'
  \b             - word boundary 
  \bis           - would match 'this is' but would not match 'thisis'
  \B             - opposite of \b, ie. the match must be 'inside' a word
  \Bis           - would match 'thatis' but would not match 'that is'
  \A \Z \z       - start and end of strings, see the web for more details

Alternatives:
  
  |              - seperate multiple options by pipe characters
  dog|cat        - match any string that contains dogs or cats
  (dog)|(cat)    - for readability some may prefer to group alternatives

Exotics not covered:

  backreferences, greedy vs. lazy vs. possessive, lookaround, modifiers, and more
  (these can become a sure cause for a definite headache) for example:

  ([0-9])\1{2}   - will match '11' '22' etc. but not '10'
  (?i)appel      - will match 'appel' as well as 'APPEL'

Re: REval v1.04x

Posted: Wed Sep 15, 2010 9:01 am
by Michael Vogel
Hi Blueznl,
no source code inside? :shock:

Re: REval v1.04x

Posted: Wed Sep 15, 2010 3:19 pm
by blueznl
Did I mess up my script? Oooops! :oops:

Let me check... Duh! Yeah, I forgot. I will change the script and upload the latest version tonight.

Re: REval v1.04x

Posted: Thu Sep 16, 2010 11:34 am
by blueznl
Uploaded the file again. It now includes the source code.

Note that I did not include the include files I always use, g_spot.pb and x_lib.pb. If you want to build the executable or run/test the source you can download those two together with CodeCaddy or SweetSpot. You can probably easily remove any references to those two files anyway.

Re: REval v1.04x

Posted: Sun Feb 05, 2012 5:23 pm
by blueznl
Updated to v1.05x.

Cleaned up the code a little, changed layout a bit, and added a box at the bottom for 'extracted' data.

Re: REval v1.05x

Posted: Thu Feb 09, 2012 11:48 pm
by Amundo
Thanks blueznl, nicely done (as always), thanks for sharing the source as well.

(Useful links under the "Help" menu item, as well)

Re: REval v1.05x

Posted: Tue Jul 30, 2013 11:18 pm
by blueznl
Minor update. Can't recall what it was, probably just a newer version of x_lib and a little larger font. I'm getting older myself, the eyes do not always cooperate :-)

Re: REval v1.05x

Posted: Mon Mar 07, 2016 4:57 pm
by Michael Vogel
Hi Blueznl,
maybe someone has downloaded your program, it seems so, that is has gone... :shock:

Re: REval v1.05x

Posted: Tue Mar 08, 2016 9:33 am
by Kwai chang caine
Yes it is, full of empty :lol: :wink:

Re: REval v1.05x

Posted: Tue Mar 08, 2016 4:21 pm
by applePi
i have found v1.04 on external hard disk, can't find v1.05.
but it highlights the whole line and not what we want exactly inside the line
http://wikisend.com/download/868550/reval.zip

the instructions
Image

EDit: chrome does not allow downloading the file since it contains reval.exe + reval.pb reval.txt. i am trying to check the file with www.virustotal.com. it is still too busy. may be it is a false positive

Re: REval v1.05x

Posted: Thu Mar 10, 2016 11:27 pm
by blueznl
Weird. Looks like the archive was empty for some reason. Uploading v1.08 it as we speak. Or type.

Re: REval v1.05x

Posted: Sat Mar 12, 2016 8:26 am
by Michael Vogel
blueznl wrote:Weird. Looks like the archive was empty for some reason. Uploading v1.08 it as we speak. Or type.
Another miracle, when I download it now, it doesn't contain version 1.08, but 1.09 :mrgreen:

Re: REval v1.05x

Posted: Sat Mar 12, 2016 12:32 pm
by blueznl
Now you know why I keep a DeLorean in the garage...

Re: REval v1.05x

Posted: Mon Mar 14, 2016 9:55 pm
by tj1010
It's actually impressive OP documents regex better than most regex documentation..

Re: REval v1.10

Posted: Mon May 29, 2017 1:36 pm
by blueznl
Update 1.10:

- Fixed link to survival guide
- Recompiled with 5.50 x86

Download:

- Changed my homepage but it's still there :-)
- http://www.ninelizards.com/purebasic/pu ... .htm#reval