jbl wrote:
I am having trouble with a regex in perl. I have an array that looks like this: Abilene,KS,67410,1019 2000 Ave,38.88254,-97.20204,Grant Town Fire Dist *Arlington,KS,67514,100 W Main St,Reno County Fire Dist 4 Abilene,KS,67410,1463 3325 Ave,39.079136,-97.1181,Sherman Township Fire District *Beattie,KS,66406,305 Whiting St,Beattie Rural Fire District No 3 Agra,KS,67621,1752 E 1100 Rd,39.749302,-99.12297,Phillips County Rural Fire District 3aI want to remove all of the (2) lines not containing a valid northern lattitude within commas ie... ,39.xxxxx, This will not work for me in perl $tempContent =~ s/^((?!,\d{1,2}\.\d{1,16},).)*$\n//g; This works in UltraEdit: ^(?:(?!,\d{1,2}\.\d{1,16},).)*$\r\n This works also with EditPadPro ^(?:(?!,\d{1,2}\.\d{1,16},).)*$\r\n as does ^((?!,\d{2,3}\.\d{1,16},).)*$\r\n It may be a simple fix but I cannot see it. Thanks
I presume you're trying to use $ to match before a newline at the end of the string, but you're actually using the $\ (output record separator) variable followed by 'n'. There's no need to use both, and just a dollar is conventional.
After that, I don't really understand your regex. You are matching a line which is an indefinite repetition of anything that doesn't match /,\d{1,2}\.\d{1,16},/ followed by a single wild character /./. How is that supposed to work?
Do you really have an array? Writing a text substitution will leave you with an array with some elements blank, and $tempContent will be set, not to content of any sort, but to the number of substitutions made - presumably 1 or 0.
It sounds like you may need grep, with a simpler regex. How about my @filtered = grep(not(m/\b\d+\.\d+\b/), @data); HTH, Rob -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
