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. Help building expression

Help building expression

Scheduled Pinned Locked Moved Regular Expressions
help
3 Posts 2 Posters 17 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.
  • J Offline
    J Offline
    jpc2879
    wrote on last edited by
    #1

    Hi, I'm trying to get some expression using regexp that extracts highlighted numbers:

    Traveller-CxFlight-895-20240819-1903
    Traveller-ETDChange-45-20240819-1903
    M-TX6102-20240819-FOC
    M-TX7156/20240819

    Any help would be appreciated.

    K 1 Reply Last reply
    0
    • J jpc2879

      Hi, I'm trying to get some expression using regexp that extracts highlighted numbers:

      Traveller-CxFlight-895-20240819-1903
      Traveller-ETDChange-45-20240819-1903
      M-TX6102-20240819-FOC
      M-TX7156/20240819

      Any help would be appreciated.

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #2

      Based on what you have here you're looking for the first string of digits in a string. Something like ^[^0-9]+([0-9]+).* should extract the digits. Vary for your flavour of regex Explanation:

      ^ anchors to left
      [^0-9]+ matches all non-digits (at least one. Maybe use *
      if you may have digits at start of text
      ([0-9]+) extract a string of digits, at least one
      .* matches rest of string

      "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

      J 1 Reply Last reply
      0
      • K k5054

        Based on what you have here you're looking for the first string of digits in a string. Something like ^[^0-9]+([0-9]+).* should extract the digits. Vary for your flavour of regex Explanation:

        ^ anchors to left
        [^0-9]+ matches all non-digits (at least one. Maybe use *
        if you may have digits at start of text
        ([0-9]+) extract a string of digits, at least one
        .* matches rest of string

        "A little song, a little dance, a little seltzer down your pants" Chuckles the clown

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

        Your solution works great! Thanks a lot for your help :)

        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