home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!gumby!destroyer!ubc-cs!dhami
- From: dhami@cs.ubc.ca (Mandeep S Dhami)
- Subject: >split !!
- Message-ID: <1992Aug31.013131.16385@cs.ubc.ca>
- Summary: use an impossible char.
- Keywords: split, \:,
- Sender: usenet@cs.ubc.ca (Usenet News)
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Date: Mon, 31 Aug 92 01:31:31 GMT
- Lines: 29
-
- >
- > What I am looking for, is something like in lex:
- >
- > [^\\]/: {split();}
- >
- > Where the split will only be done if the perceading
- > character is not a \.
- >
- > Any ideas?
- >
-
- Try:
- $x='a:b:c\:d:e"; # Or any other way!
- $x=~s/\\\:/\377/g; # Or any other char NOT in input domain
- @x=grep(s/\377/\:/g||1,split(':',$x));
- # ^^ or \\\: depending on if you want c\:d or c:d
-
- Also, instead of substituting \: (as in your posting
- you may substitute \377 and save a step).
-
- Hope this helps.
-
- Mandeep.
- dhami@cs.ubc.ca
- --
- __________________________________________________________________
- "I'm very brave generally," he went on in a low voice:
- "only to-day I happen to have a headache."
- -- Lewis Carroll
-