Ask a Question related to PERL Miscellaneous, Design and Development.
-
Jason Quek #1
recognising a special character inside [^]
Hi
What I need to do is to print only '1|2|3'.
#----------------------------------------------------------------
@array = (
'1',
'1|2',
'1|2|3',
'1|2|3|4',
'1|2|3|4|5',
'1|2|3|4|5|6'
);
$string = '1|2';
foreach (@array)
{
if ($_ =~ /^$string\|([^\|]*)$/)
{
print "$_\n";
}
}
#----------------------------------------------------------------
But the above code prints the entire array out.
I believe the problem lies with ([^\|]*).
How do I correctly tell Perl to recognise the pipe | character inside
([^\|]*)
Any help would be appreciated.
Jason Q.
Jason Quek Guest
-
MX 7 and CGI special character problem
The umlauts have stopped working in our application since upgrading to Coldfusion MX 7 and Apache 2.0.43. A html form is sent to coldfusion. A... -
how to query a column name with special character
i was able to create a table with a column name abc\ on db2 v8.1 on windows, but when i do the query select abc\ from table, i get error '\' is... -
Special Character search lik
How did u insert mycafé in database ?? Use same client settings which u used for insert. Hope this helps. ( Else post ur settings or method to... -
Special character for SM?
Hi all, I need to insert the character "SM", similar to special character "TM". Is there a keystroke for this like TM? Would rather use htm text... -
I need a special character....
The a in Mangels need an umlaut, please. Eleanor -
Brian Wakem #2
Re: recognising a special character inside [^]
"Jason Quek" <qjason@cyberway.com.sg> wrote in message
news:3f66b174.7039109@news.starhub.net.sg...if ($_ =~ /^\Q$string\E\|([^\|]*)$/) {> Hi
>
> What I need to do is to print only '1|2|3'.
>
> #----------------------------------------------------------------
> @array = (
> '1',
> '1|2',
> '1|2|3',
> '1|2|3|4',
> '1|2|3|4|5',
> '1|2|3|4|5|6'
> );
>
> $string = '1|2';
>
> foreach (@array)
> {
> if ($_ =~ /^$string\|([^\|]*)$/)
> {
> print "$_\n";
> }
> }
> #----------------------------------------------------------------
>
> But the above code prints the entire array out.
>
> I believe the problem lies with ([^\|]*).
>
> How do I correctly tell Perl to recognise the pipe | character inside
> ([^\|]*)
>
> Any help would be appreciated.
....
}
--
Brian Wakem
Brian Wakem Guest
-
Tad McClellan #3
Re: recognising a special character inside [^]
Jason Quek <qjason@cyberway.com.sg> wrote:
> $string = '1|2';
vertical bars are special in a regex, you must backslash them
if you want a literal one:
my $string = '1\|2';
> I believe the problem lies with ([^\|]*).
Nope.
--
Tad McClellan SGML consulting
[email]tadmc@augustmail.com[/email] Perl programming
Fort Worth, Texas
Tad McClellan Guest



Reply With Quote

