Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Regexp helper - any suggestions?

Regexp helper - any suggestions?

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Thu 30 Dec 2004 11:14 PM (UTC)
Message

As a final tweak to version 4 of MUSHclient, I am adding a helpful 'regexp helper' menu. What this does (intends to do anyway) is to make it easier to generate regular expressions by letting you choose common actions from a menu, see example below ...

My question for people who use regular expressions regularly is: 'Are there other things you would like to see on the menu?'

I want the menu to be useful but not too cluttered with things you don't normally need (there is the documentation for that).


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Thu 30 Dec 2004 11:18 PM (UTC)

Amended on Thu 30 Dec 2004 11:46 PM (UTC) by Nick Gammon

Message

Below are the characters that get inserted for each menu item:

Any Character .
Character In Range []
Character Not In Range [^]
Whitespace \s
Not Whitespace \S
Decimal Digit (0-9) \d
Not Decimal Digit \D
Letter (A-Z) [[:alpha:]]
Not Letter [[^:alpha:]]
Word (A-Z, 0-9, _) \w
Not Word \W
Beginning Of Line ^
End Of Line $
End Of Subject \z
Word Boundary \b
Tagged Expression ()
Named Expression (?P<name>)
Or |
Comment (?#)
0 or More Matches {0,}
1 or More Matches {1,}
0 or 1 Match {0,1}

If the table disagrees with the screenshot, it is because I have started tweaking the descriptions a bit. The table above is what is planned in the release.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 30 Dec 2004 11:30 PM (UTC)
Message
Some other possible candidates are:

[[:alnum:]] letters and digits
[[:ascii:]] character codes 0 - 127
[[:blank:]] space or tab only
[[:cntrl:]] control characters
[[:digit:]] decimal digits (same as \d)
[[:graph:]] printing characters, excluding space
[[:lower:]] lower case letters
[[:print:]] printing characters, including space
[[:punct:]] printing characters, excluding letters and digits
[[:space:]] white space (not quite the same as \s)
[[:upper:]] upper case letters
[[:word:]] "word" characters (same as \w)
[[:xdigit:]] hexadecimal digits

\ general escape character


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Thu 30 Dec 2004 11:45 PM (UTC)
Message
Sounds like a great idea, Nick. How difficult would it be to have submenus? I imagine it might make things a little easier (and less cluttered, thus allowing more stuff *grin*) if you have submenus for things like:
- character class
- quantifiers
- position markers
- grouping

As far as more things on the menu, your list seems fine to me. With submenus, you could have more, even the less frequently used stuff... you could put that stuff into a separate category.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #4 on Fri 31 Dec 2004 01:19 AM (UTC)

Amended on Fri 31 Dec 2004 01:21 AM (UTC) by Nick Gammon

Message
Good idea. I've made a few submenus instead of one big one, but most of it is the same as listed above. I've also added:

[[:alnum:]] letters and digits
[[:lower:]] lower case letters
[[:upper:]] upper case letters
[[:xdigit:]] hexadecimal digits

and:

Group Without Capture: (?:)

Positive Lookahead: (?=)
Negative Lookahead: (?!)
Positive Lookbehind: (?<=)
Negative Lookbehind: (?<!)

4 Matches Exactly: {4}
5 to 10 Matches: {5,10}

The last two are really examples, to show how you might match 4 things (eg. a{4} would match "aaaa") or a range (eg. 3 to 5 digits would be: [0-9]{3,5} )


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


12,731 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.