[Israel.pm] regexp

Issac Goldstand margol at beamartyr.net
Sun Jun 25 01:40:12 PDT 2006


This isn't necessarily the "best" way, but it should work...

(Assuming string is in $_)
# "aaa<asd>='asd'/6>bbb<asd>='asd'/3>ccc<asd>='asd'/5>ddd###"
# Dump the "in between" text (which is static and not important)
s/<asd>='asd'\/\d+//g;
# "aaa>bbb>ccc>ddd###"
# Remove trailing garbage
s/###$//;
# "aaa>bbb>ccc>ddd"
# Split tokens
my @list=split(/>/);
# aaa
# bbb
# ccc
# ddd


  Yitzchak

Ernst, Yehuda wrote:
> Hello!
> 
> 
> I have a text like this
> 
> "aaa<asd>='asd'/6>bbb<asd>='asd'/3>ccc<asd>='asd'/5>ddd###"
> 
> I need to extract the aaa bbb ccc ddd
> between is the same <asd>='asd'/6>
> just the number can be different
> 
> i do not know how many <asd>='asd'/6> are there the end is like this ###
> 
> any ideas?
> 
> Thanks
> 
> Yehuda Ernst                        יהודה ארנסט
> NDS Technologies Israel Ltd. mailto:yernst at nds.com>
> Jerusalem          Tel:  +972 (2) 589-4427
> PO Box 23012    Fax: +972 (2) 589-4825
> Israel.    91235    Cell  +972 54 5664427
> 
> ***********************************************************************************
> This email message and any attachments thereto are intended only for use by the addressee(s) named above, and may contain legally privileged and/or confidential information. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the postmaster at nds.com and destroy the original message.
> ***********************************************************************************
> 
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl



More information about the Perl mailing list