Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Tricky Perl Regurlar (Again) thanks

Expand Messages
  • ramprasad@netcore.co.in
    This did not help me anyway I learnt from the Regexp I ultimately did this my @allvals = map {s/ / /g; substr $_, 0} $str =~ /0, (.*?[^ ]) /g; Your
    Message 1 of 2 , Nov 30, 2001
    • 0 Attachment
      This did not help me anyway I learnt from the Regexp
      I ultimately did this
      my @allvals = map {s/\\\'/\'/g; substr $_, 0}
      $str =~ /0,\'(.*?[^\\])\'/g;

      Your Idea will not help if the array element of the string itself
      contained 0, like this
      0,'hello world\'s people' 0,'It is for me' 0,'It\'s no 0, for me'

      which is possible after all the string was from XML Parser output.


      I now learnt I had to to a substr in the map exp else the block beyond
      it is not taken as an array of strings .... surprising ,though ok for
      me


      --- In perl-beginner@y..., "Charles K. Clarkson" <cclarkson@h...>
      wrote:
      > <ramprasad@n...>
      >
      > : Hi
      > : I had made a mistake in giving the test string. I cannot use the
      map
      > : expression because there may be some other characters which I dont
      > : want before the 0,
      > : eg.
      > : 0,'hello\'a' ddd 0,'abc',0,'def'
      > :
      > : sorry for before
      >
      > [ mutter, mutter, <expletive deleted>, mumble, mumble ]
      >
      >
      > my @all_vals =
      > map {s/[^']*$//; substr $_, 1, -1}
      > $str =~ /0,([^0]*)/g;
      >
      > Or for the map impaired:
      >
      > my @all_vals = $str =~ /0,([^0]*)/g;
      > foreach (@all_vals) {
      > s/[^']*$//; # remove everything after
      the '
      > $_ = substr $_, 1, -1; # lop off the first and last '
      > }
      >
      > HTH,
      > Charles K. Clarkson
      > Clarkson Energy Homes, Inc.
      >
      >
      >
      > Since the masses of the people are inconstant, full of unruly
      desires,
      > passionate, and reckless of consequences, they must be filled with
      fears to keep
      > them in order. The ancients did well, therefore, to invent gods, and
      the belief
      > in punishment after death.
      > - Polybius -- Roman Historian
    Your message has been successfully submitted and would be delivered to recipients shortly.