Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Regular Expressions
  4. REGEX to find space followed by number 1 then letter

REGEX to find space followed by number 1 then letter

Scheduled Pinned Locked Moved Regular Expressions
regexhelptutorial
3 Posts 3 Posters 26 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Richard Parker from London
    wrote on last edited by
    #1

    Hi Been playing around but cant figure this out, I 'm looking for a way to identify where there is a space followed by the number 1 and a letter of the alphabet, below is an example of the text and I have underlined where I want the identification to be (so I can then replace/split at that point only) but can't seem to figure it out

    -ABC046Y 1SMITH/FREDMR
    .L/JCD5CQ
    .R/TKNE HK1 6002300348396/1-SMITH/FREDMR
    .R/SEAT HK1 9F
    .R/FQTV AB 60042576-1SMITH/FREDMR 1DOE/JANEMISS
    .L/JC93QW
    .R/TKNE HK1 6002300219029/2-1DOE/JANEEMISS
    .R/SEAT HK1 8A
    .R/CHKD HK1 011-1DOE/JANEMISS 1PRESLEY/ELVISMR-A2

    Tried a few things with regex editor but it always finds other things as well which I don't want Hope someone can help Many thanks

    Richard DeemingR 1 Reply Last reply
    0
    • R Richard Parker from London

      Hi Been playing around but cant figure this out, I 'm looking for a way to identify where there is a space followed by the number 1 and a letter of the alphabet, below is an example of the text and I have underlined where I want the identification to be (so I can then replace/split at that point only) but can't seem to figure it out

      -ABC046Y 1SMITH/FREDMR
      .L/JCD5CQ
      .R/TKNE HK1 6002300348396/1-SMITH/FREDMR
      .R/SEAT HK1 9F
      .R/FQTV AB 60042576-1SMITH/FREDMR 1DOE/JANEMISS
      .L/JC93QW
      .R/TKNE HK1 6002300219029/2-1DOE/JANEEMISS
      .R/SEAT HK1 8A
      .R/CHKD HK1 011-1DOE/JANEMISS 1PRESLEY/ELVISMR-A2

      Tried a few things with regex editor but it always finds other things as well which I don't want Hope someone can help Many thanks

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Try either "\s1[A-Za-z]" if the "space" could be any whitespace character, or " 1[A-Za-z]" if it has to be a literal space character. Demo[^] If you want to get fancy, and match each 1 which is preceded by a space and followed by a letter, without capturing the space and the letter, then you'll need zero-width assertions. Eg: "(?<=\s)1(?=[A-Za-z])" Demo[^] If that still doesn't work, you'll need to specify which regex "flavour" you're using - PHP, JavaScript, .NET, etc. - and provide more precise details of what you have tried and what the problem is.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      J 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Try either "\s1[A-Za-z]" if the "space" could be any whitespace character, or " 1[A-Za-z]" if it has to be a literal space character. Demo[^] If you want to get fancy, and match each 1 which is preceded by a space and followed by a letter, without capturing the space and the letter, then you'll need zero-width assertions. Eg: "(?<=\s)1(?=[A-Za-z])" Demo[^] If that still doesn't work, you'll need to specify which regex "flavour" you're using - PHP, JavaScript, .NET, etc. - and provide more precise details of what you have tried and what the problem is.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        Richard Deeming wrote:

        you're using - PHP, JavaScript, .NET, etc

        At least for those I don't think it matters. All of those (and Java) use for the most part a fully compatible version of regex which matches Perl.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups