Jump to content

Space?


lollipop2468

Recommended Posts

Apologies for the ridiculousness of this question!

 

I am a newbie so please be patient!

 

I am trying to match groups of numbers and letters, however how  do I match a possible space in an expression? By this I mean if a user entered 'ABCD 1234' how can I get it to match with ABCD1234?

 

This is most likely a very simple piece of code - ive searched all afternoon and can not find anything to explain how it is done!

 

Thanks

Link to comment
Share on other sites

Thanks requinix!

 

Something so simple! I'm trying to learn the basics and struggling to find a guide that explains it easily!

 

So will ' ?' check for either space or no space?

 

If a line was approved as either having/not having a space, is it then possible to strip out the space if you were then going to insert that line into a database?

 

 

Link to comment
Share on other sites

If a line was approved as either having/not having a space, is it then possible to strip out the space if you were then going to insert that line into a database?

Sure. One way would be to "capture" the letters and numbers, then piece the two parts back together.

 

I felt like drawing some ASCII art. Probably because I'm really tired.

       "ABCD 1234"
         /  |   \
        /   |    \
       V    V     V
    ______      ______
   /      \    /      \
   |      |    |      |
/^([A-Z]{4}) ?([0-9]{4})$/
  |        |  |        |
  \________/  \________/
        \        /
     $1  \      /  $2
          \    /
           V  V
          "$1$2"
            |
            V
        "ABCD1234"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.