ot: regular expression help

2009-07-07 Thread Aryeh M. Friedman
I am attempting to make (without the perl expansions) a regular expansion that when used as a delim will split words on any punction/whitespace character *EXCEPT* $ (for java people I want to feed it into something like this: for(String foo:input.split([insert regex here]) ...

Re: ot: regular expression help

2009-07-07 Thread Steve Bertrand
Aryeh M. Friedman wrote: I am attempting to make (without the perl expansions) a regular expansion that when used as a delim will split words on any punction/whitespace character *EXCEPT* $ (for java people I want to feed it into something like this: for(String foo:input.split([insert regex

Re: ot: regular expression help

2009-07-07 Thread Matthew Seaman
Aryeh M. Friedman wrote: I am attempting to make (without the perl expansions) a regular expansion that when used as a delim will split words on any punction/whitespace character *EXCEPT* $ (for java people I want to feed it into something like this: for(String foo:input.split([insert regex

Re: Regular Expression Help

2008-12-01 Thread Drew Tomlinson
Matthew Seaman wrote: Drew Tomlinson wrote: Matthew Seaman wrote: % perl -p -e 's/cn=([^ ,]+) ([^,]+),/cn=$2 $1,/' foo.txt I still don't really understand *why* the above works but I'm trying to pick it apart now. The RE breaks down like this: /cn=([^ ,]+) ([^,]+),/ cn=

Regular Expression Help

2008-11-30 Thread Drew Tomlinson
I'm attempting to take an ldiff file and flip first/last name order. However I can not figure out how to match hyphenated last names. In vim, my current search/replace string is: %s/cn=\(\w\+\-*\) \(\w\+\),/cn=\2 \1,/gc This will match: cn=Smith Joe, and replace it with: cn=Joe Smith,

Re: Regular Expression Help

2008-11-30 Thread prad
On Sun, 30 Nov 2008 09:14:53 -0800 Drew Tomlinson [EMAIL PROTECTED] wrote: I'm attempting to take an ldiff file and flip first/last name order. you can try using sh (i'm using zsh) file data.txt has the following: joe brown joe brown-smith file t.sh is coded as: #!/usr/local/bin/zsh #

Re: Regular Expression Help

2008-11-30 Thread Matthew Seaman
Drew Tomlinson wrote: I'm attempting to take an ldiff file and flip first/last name order. However I can not figure out how to match hyphenated last names. In vim, my current search/replace string is: %s/cn=\(\w\+\-*\) \(\w\+\),/cn=\2 \1,/gc This will match: cn=Smith Joe, and replace it

Re: Regular Expression Help

2008-11-30 Thread Giorgos Keramidas
On Sun, 30 Nov 2008 09:14:53 -0800, Drew Tomlinson [EMAIL PROTECTED] wrote: I'm attempting to take an ldiff file and flip first/last name order. However I can not figure out how to match hyphenated last names. In vim, my current search/replace string is: %s/cn=\(\w\+\-*\) \(\w\+\),/cn=\2

Re: Regular Expression Help

2008-11-30 Thread Drew Tomlinson
Matthew Seaman wrote: Drew Tomlinson wrote: I'm attempting to take an ldiff file and flip first/last name order. However I can not figure out how to match hyphenated last names. In vim, my current search/replace string is: %s/cn=\(\w\+\-*\) \(\w\+\),/cn=\2 \1,/gc This will match:

Re: Regular Expression Help

2008-11-30 Thread Matthew Seaman
Drew Tomlinson wrote: Matthew Seaman wrote: % perl -p -e 's/cn=([^ ,]+) ([^,]+),/cn=$2 $1,/' foo.txt I still don't really understand *why* the above works but I'm trying to pick it apart now. The RE breaks down like this: /cn=([^ ,]+) ([^,]+),/ cn= Match literal

Re: Regular Expression Help

2008-11-30 Thread Olivier Nicole
Hi, I still don't really understand *why* the above works but I'm trying to pick it apart now. Whenever I have a doubt about regular expression, I use the regexp coach. It works on Windows, but I find it a very intelligent and usefull tool. http://weitz.de/regex-coach/ Best regards, Olivier