Log in

View Full Version : Regular Expression Experts?



the-mk
10-13-2008, 01:41 PM
Are there some regular expression experts out there?

I have a software, which uses regular expressions as check mechanism on how a string should look like. I want to achieve that only "standard characters" are "valid", but no character which a file system doesn't like...

currently this one makes me headache:

%^[-A-Za-z0-9" "_]{1,40}

can someone explain me what these things mean?
the things in the brackets should mean the following characters: "-", characters from A to Z (upper and lower case), numbers from 0 to 9, " " (blank) and "_" (underscore)
{1,40} should mean from first sign to sign number forty. Is this still regular expression?
%^ --> what should that mean?

can someone please bring light into that thing to me?

Thanks in advance!

gopher_yarrowzoo
10-13-2008, 02:02 PM
I'm no reg exp expert but I've had a quick shifty at a program I used that uses reg exp for search


%^ - start of line
[-A-Za-z0-9" "_] - match "A-Z","a-z","0-9"," " & "_" also match "-" might want to put the - as "-" to make sure
{1,40} - can't see in the version I use so idea if it will work but in mine it an "expression" on in it's own right, looking at it I can now see it's of PCRE type so it should work.
Also add "." as "dot" is a valid char.

Bok
10-13-2008, 04:21 PM
Most likely the {} are line numbers ? i.e. match line 1 - 40

Hard to tell from the context though.

Gopher has the rest of the regexp correct. :rock: