in reply to RegEx for users who dont know RegEx
Something like this?
($reg_exp = $user_query) =~ s/(\W)/$1 eq '*' ? "\\S*" : "\\$1"/ge;
It can be used as follows:
# File as an array of lines: @matching_lines = grep { /$reg_exp/ } @lines_to_search;
or
# File in a scalar: @matching_lines = $file =~ /^(.*${reg_exp}.*)$/mg;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RegEx for users who dont know RegEx
by The Mad Hatter (Priest) on Dec 23, 2004 at 17:36 UTC | |
by ikegami (Patriarch) on Dec 23, 2004 at 17:39 UTC |