$var =~ /n\\(.?)\\/
This will match a 'n' followed by a '\' followed by 0 or 1 instance of any char followed by a '\'.
Thus in the case you provide it will not match anything.
There are two possibilities on what your want in your $1:
either what is between two '\' or what is between the first and last '\'
Which is either the regex
$var =~ /n\\(.*?)\\/ or
$var =~ /n\\(.*)\\/
The difference may be subtle, but look at the strings:
$var='{some text} n\{some text}\{some more text}\';
and
$var='{some text} n\{some text}\{some more text}'; #Your old version
$1 in the first $var will become '{some text}' with the first regex and '{some text}\{some more text}' with the second.
$1 in the second $var will in either case be '{some text}'
T
I
M
T
O
W
T
D
I
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.