Doesn't seem to work. #MO and # MO do not match. Tried the regex tester at http://www.internetofficer.com/seo-tool/regex-tester/ and it says "no match" | [reply] |
Hi finfan,
..Doesn't seem to work. #MO and # MO do not match. Tried the regex tester at http://www.internetofficer.com/seo-tool/regex-tester/ and it says "no match"..
I know the code posted by toolic worked, I wanted to find out why it wasn't working on the website you mentioned. Tried it out and it worked with the following result:
Regular Expression Test Results
Tested pattern: ^#\s*[a-z]+
Applied options:
the comparison was case-insensitive
String 1: #MO
Result : true
String 2: # MO
Result : true
String 3: #mo
Result : true
String 4: # mo
Result : true
String 5: # 555
Result : false
May be the question, one should be asking is: How are you doing these regexp?
If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me
| [reply] [d/l] |
"Doesn't seem to work. #MO and # MO do not match."
That sounds like you forgot the 'i' modifier at the end of "/^#\s*[a-z]+/i".
"Tried the regex tester at http://www.internetofficer.com/seo-tool/regex-tester/ and it says "no match""
That site clearly states "We use Perl-style regular expressions." (not Perl regular expressions).
It also seems to have limited functionality: it has a checkbox for the 'i' modifier and nothing for any of the other modifiers (see /PATTERN/msixpodualgc in "perlop: Regexp Quote-Like Operators").
Why not try it in a real perl script.
As ++toolic provided you with the complete code, it's a simple copy-paste operation.
| [reply] [d/l] [select] |
$ cat 1078855.pl
use warnings;
use strict;
while (<DATA>) {
print if /^#\s*[a-z]+/i;
}
__DATA__
#MO
# MO
#mo
# mo
# 555
$ perl 1078855.pl
#MO
# MO
#mo
# mo
$
| [reply] [d/l] |