REval v1.05x

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

REval v1.05x

Post 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'
Last edited by blueznl on Sun Feb 05, 2012 5:24 pm, edited 1 time in total.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: REval v1.04x

Post by Michael Vogel »

Hi Blueznl,
no source code inside? :shock:
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: REval v1.04x

Post 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.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: REval v1.04x

Post 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.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: REval v1.04x

Post 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.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Amundo
Enthusiast
Enthusiast
Posts: 191
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Re: REval v1.05x

Post by Amundo »

Thanks blueznl, nicely done (as always), thanks for sharing the source as well.

(Useful links under the "Help" menu item, as well)
Win8.1, PB5.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: REval v1.05x

Post 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 :-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: REval v1.05x

Post by Michael Vogel »

Hi Blueznl,
maybe someone has downloaded your program, it seems so, that is has gone... :shock:
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: REval v1.05x

Post by Kwai chang caine »

Yes it is, full of empty :lol: :wink:
ImageThe happiness is a road...
Not a destination
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: REval v1.05x

Post 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
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: REval v1.05x

Post by blueznl »

Weird. Looks like the archive was empty for some reason. Uploading v1.08 it as we speak. Or type.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Michael Vogel
Addict
Addict
Posts: 2666
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: REval v1.05x

Post 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:
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: REval v1.05x

Post by blueznl »

Now you know why I keep a DeLorean in the garage...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
tj1010
Enthusiast
Enthusiast
Posts: 621
Joined: Mon Feb 25, 2013 5:51 pm
Location: US or Estonia
Contact:

Re: REval v1.05x

Post by tj1010 »

It's actually impressive OP documents regex better than most regex documentation..
The truth hurts.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6161
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: REval v1.10

Post 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
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply