regular expression for string in c

Posted by darkie15 on Stack Overflow See other posts from Stack Overflow or by darkie15
Published on 2010-05-30T04:51:04Z Indexed on 2010/05/30 4:52 UTC
Read the original article Hit count: 277

Filed under:
|

Hi All,

I am working writing a regular expression used to validate string in C. Here is to what I have gone so far

'^"[A-Za-z0-9]*[\t\n]*"$'

for rules - A string should begin with double quotes - May not contain a newline character

However, I am not able to capture the rule for allowing '\' or '"' in a string if preceded with '\'. Here is what I tried:

'^"[A-Za-z0-9]*[\t\n]*[\\\|\\"]?"$'

But this doesn't seem to work. What might be wrong with the regular expression here?

Regards, darkie15

© Stack Overflow or respective owner

Related posts about regex

Related posts about string