TacoVendor has asked for the wisdom of the Perl Monks concerning the following question:
I am just a little less than familiar with regex's. I have used them a bit, but only in simple contexts, i.e. clearing whitespace from a string, things like that.
I have looked around, but don't seem to find the answer to this:
I have a line that I am reading into a variable that comes in the format of: "aaaaaa 1, bbbbbb 2". The a's and b's are a unique identifier that are always letters. The 1 and 2 will always be numbers. I am splitting the string into 4 seperate variables that end up like this: $1="aaaaaa" $2="1" $3="bbbbbb" $4="2". My script throws each portion of the line into its relevant variable when it comes across either whitespace or a comma. I now have data that is coming in like this: "aaaaa aaa 1, bbbbb bbb 2".
Is there some type of regex function that will allow me to remove whitespace only if it is found between letters? Something that will take "abcdef ghi 1, jklmno pqr 2" and make it become "abcdefghi 1, jklmnopqr 2" so that the rest of my script can continue running as it has until now?
Sorry this is long-winded for such a simple question, I just wanted to make sure my question was understood properly.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Question
by sauoq (Abbot) on Jan 10, 2003 at 16:28 UTC | |
|
Re: Regex Question
by Zaxo (Archbishop) on Jan 10, 2003 at 16:32 UTC | |
|
Re: Regex Question
by schumi (Hermit) on Jan 10, 2003 at 16:35 UTC | |
|
Re: Regex Question
by pike (Monk) on Jan 10, 2003 at 16:58 UTC |