0

In brief, I am puzzled as to why ~^[0-9]*?\|[0-9]*?\|.*?\|.*?\..*?\|2\|[0-9]\|.*?$~m matches 1362526368|5|Corinne E. Fischer|fischer.jpg|3|3|FischerC@smh.ca|416-864-5320|1|2|3|4|5
Note the |3| after fischer.jpg when the pattern clearly has a \|2\| in that location. Now I understand that it must be the numbers at the end that are messing with the match but I don't really know how to fix it (the numbers at the end don't have to be numbers but can be any characters). This shouldn't be an issue later when I fill in proper data but I just want to know where I'm going wrong for future reference and for my peace of mind.

If you want I can include my original data as well as my complete pattern (I made this one just to test my theory).

Thank you for your time, evidently I'm not very good with regex.

2
Contributors
2
Replies
12
Views
4 Years
Discussion Span
Last Post by IIM
0

Nevermind, it seems to be working now. I cleaned up my pattern ~^[0-9]*?\|[0-9]*?\|.*?\|.*?\.[^0-9]*?\|3\|[1-3]\|.*?\|.*?\|.*?\|.*?\|.*?\|.*?\|.*?$~m and it's working ok now. Still not sure what was wrong though...

0

the problem is because of wild card character that you have used.

~^[0-9]*?\|[0-9]*?\|.*?\|.*?\..*?\|2\|[0-9]\|.*?$~m

here .* is a wild card which allows as many characters.
And it is returning true because |2| is there in test string.Remove that and you can see it will return false.
Be careful before using wild card .If using either limit characters or type of characters.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.