in reply to Regex Search String in a Variable
> Note: I tried running the search string variable through the "qr" function, but that did not help.
qr helps
#!/usr/bin/perl use strict; use warnings; my ($text, $search); $text = "\\x1\\x2\\x3\\x4"; $search = qr/x2\\.+\\x4/; print "\nUsing variable in regex: (qr)\n"; print "Before: text = $text\n"; $text =~ s/$search/new/; print " After: text = $text\n"; __END__ Using variable in regex: (qr) Before: text = \x1\x2\x3\x4 After: text = \x1\new
L*
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex Search String in a Variable
by roho (Bishop) on May 01, 2021 at 20:59 UTC |