Can somebody write a regular expression for me... please :P

gopunk

Lifer
Jul 7, 2001
29,239
2
0
i really suck at them :p

this is an example of the lines i'm searching:

comment BUE544A_SP02 "Class Discussion List"

i need to search some files for all lines that begin with "comment" (as this line does), and within those lines, all lines that have a non-alphanumeric, non-whitespace character between the two quotation marks.

can anybody do this?

thanks! :)
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
for $line(@lines){
if ($line =~ /^comment[^"]*"[^"]*[^\sa-zA-Z\d][^"]*"/){
# do stuff
print "matched $line\n";
}
}

that should work. It's in perl, BTW :)

more specifically, your expression is: ^comment[^"]*"[^"]*[^ \n\r\ta-zA-Z0-9][^"]*"

the second version is less perl specific, it should run in most regex engines :)