|
Posted by Petr Vileta on March 6, 2008, 7:41 pm
Please log in for more thread options
Abigail wrote:
> _
> The code below *USES* regexes. So, keep it if you want to have it
> using
> a regexp.
>
> ][ if($string =~ m/A:\s+([^B]+)\s+B:\s+(.+)/) { $myA = $1; $myB =
> $2;} ][ elsif($string =~ m/A:\s+(.+)/) { $myA = $1; $myB = '';}
> ][ elseif($string =~ m/B:\s+(.+)/) { $myA = ''; $myB = $1;}
> ][ else {$myA = $myB = '';}
>
Yes, this is example only, you are exact too much :-)
I forgot to mention that A: and B: are "constatnst", so if some of these *is*
in string then it is exactly "A:" or "B:", but parts after space are variable.
In other word string can contain one of
"A: " + some variable part
or
"B: " + some variable part
or both.
--
Petr
Skype: callto://fidokomik
Na mail uvedeny v headeru zpravy nema cenu nic posilat, konci to v PR*
:-)
Odpovidejte na petr na practisoft cz
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>
|
|
Posted by David Filmer on March 10, 2008, 5:59 pm
Please log in for more thread options
Abigail wrote:
> give ($string) {
> when ("A: aaa B: bbb") {
Is that Perl6?
|
|
Posted by Abigail on March 10, 2008, 6:23 pm
Please log in for more thread options _
David Filmer (usenet@davidfilmer.com) wrote on VCCCV September MCMXCIII
?? Abigail wrote:
??
?? > give ($string) {
?? > when ("A: aaa B: bbb") {
??
?? Is that Perl6?
I've no idea whether that works in Perl6. I don't care about Perl6.
But I'm sure it's Perl5. Assuming you have a recent version of Perl5.
Abigail
--
A perl rose: perl -e '@}>-`-,-`-%-'
|
|
Posted by Frank Seitz on March 10, 2008, 6:40 pm
Please log in for more thread options David Filmer wrote:
> Abigail wrote:
>>
>> give ($string) {
>> when ("A: aaa B: bbb") {
>
> Is that Perl6?
It's Perl 5.10 with "use feature 'switch'".
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/ Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
|
|
Posted by Michele Dondi on March 11, 2008, 4:59 pm
Please log in for more thread options On Mon, 10 Mar 2008 13:59:19 -0800, David Filmer
>> give ($string) {
>> when ("A: aaa B: bbb") {
>
>Is that Perl6?
No, it's Perl 5.10, but it should be C<given>, anyway.
Michele
--
->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
|
| Similar Threads | Posted | | Need RegExp | November 15, 2004, 7:32 pm |
| looking for a better regexp | November 25, 2004, 6:35 pm |
| RegExp Help | December 6, 2004, 8:16 pm |
| RegExp Help | December 6, 2004, 3:57 pm |
| regexp | February 23, 2005, 4:29 pm |
| UTF-8 in regexp with 5.8.1 | April 10, 2005, 8:22 pm |
| Help with regexp. Can you do better | September 27, 2005, 5:24 am |
| regexp | May 9, 2006, 9:43 am |
| Regexp help. | June 2, 2006, 9:57 am |
| regexp | January 30, 2007, 6:30 am |
|