# string matching - PERL Miscellaneous

I need to remove $b from$a $a = "abc/\def/ghi" ;$b = "abc/\def"; Regards Kamal...

1. ## string matching

I need to remove $b from$a

$a = "abc/\def/ghi" ;$b = "abc/\def";

Regards
Kamal
kamal Guest

2. ## Re: string matching

kamal wrote:
> I need to remove $b from$a
>
> $a = "abc/\def/ghi" ; >$b = "abc/\def";
Simple, really.

$a = "/ghi"; Or try regexes.$a =~ s/\Q$b//; # Removes first occurrance. Steffen -- n=([283488072,6076],[2105905181,8583184],[1823729722,9282996],[281232, 1312416],[1823790605,791604],[2104676663,884944]);$b=6;c=' -/\_|'=~/./g
;for(n){for$n($_){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[c]=$h}reverse
0..11;pushp,map{$c[$_]}c[reverse$b..$#c];$#c=$b-1}$p[p]="\n"}printp; Steffen Müller Guest 3. ## Re: string matching [email]kamalindia.ti.com[/email] (kamal) writes: > I need to remove$b from $a$a =~ s/\Q$b//; (Or you can use a non-Perlish solution using substr() and index() that'll take longer to write, be difficult to read, look less like Perl but will probably run a little faster). >$a = "abc/\def/ghi" ;
> \$b = "abc/\def";
BTW you should always develop with warnings on. The above generates
two "Unrecognized escape \d passed through" warnings.

This looks like a homework question. The s/// operator is usually
covered quite early in any Perl course.

If this is a taught course be aware there's a fair chance your teacher
will be monitoring Usenet so you are not going to fool anyone.

If you are leaning from a book, doesn't it have answers in the back?

If you are not on a Perl course then perhaps you should be. Please do
not take offense when I say if you are at the level where you need to
ask many of this level of question you'd probably beniefit more from
some sort of structured Perl course more than you will from asking odd
isolated questions on Usenet.

(Of course, it could just be you had a mental block, in which case
disregard the above).

--
\\ ( )
. _\\__[oo
.__/ \\ /\
. l___\\
# ll l\\
###LL LL\\
Brian McCauley Guest

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•