This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

regular expression question

Old posts that have not been replied to for several years.
Locked
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

regular expression question

Post by droolin »

Im trying to build a regular expresion that will catch special characters within a nick, and I am using the free regular expression utility pcre to test with before I put it into the script. To this point, I have been able to correctly identify the following special characters via my regular expresion: (){}|[]`^, basicatly I just made it a regular expression class.

Code: Select all

[\[\](){}|'`^]
The only special character that I seem to have problems with identifying is the escape character \. The tutorials that I have read say that you should do this: \\ for it to be considered a regular character. But, alas... Not working.

Can anyone offer any sugestions on how I can identify that character in a regular expresion? Or, should I forgo the regular expresion option for that character only, and use an array to look for it???

Thank you in advance.

droolin
Imagination is more important than knowledge. Albert Einstein 1879-1955
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Depends if you're using { } or " " to enclose the regular expression. If { }, then \\ is right. Otherwise, you actually need \\\\.
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

hmmmm

Post by droolin »

I have not moved anything into the tcl script yet, I was using the utility like I said for testing. I had enclosed all the special characters I was looking for within the [ ], and it worked. Im new to this, never did regular expresion at all before. Thats why I grabbed that utility to help me test.
Chuckle, I had tried \\ and \\\.. but, not \\\\.
thank you, I will try that next.

droolin
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

You'd be better off using tclsh to do the testing. Not all regular expression parsers are the same.
User avatar
droolin
Halfop
Posts: 64
Joined: Thu Jul 24, 2003 9:07 pm
Contact:

I wondered if that was part my problem

Post by droolin »

I know that the utility I was using was written for perl and not tcl. And the reading I have done, tutorials on regular expresion. I have seen some differences(I think) between tcl and perl regular expressions. I am also writting some things in perl also, so its not a wasted download.
What you just told me was a huge help. I didn't even know I had this utility on my unix box, and I was testing on my windows machine. After a bit of reading, I will definatly use this utility alot. Specially after the bit I just tested. Again, what you just told me is a huge help. Both for now, and later projects.
Thank you again.

droolin
Locked