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.


In reply to Regex Question by TacoVendor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.