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. Visual Basic
  4. Struggeling with Regex

Struggeling with Regex

Scheduled Pinned Locked Moved Visual Basic
regexhelpjsonquestion
3 Posts 2 Posters 0 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.
  • S Offline
    S Offline
    Sonhospa
    wrote on last edited by
    #1

    Hello everybody, I've been struggeling with a Regex for hours now, and I hope someone of you can help me out of this. I'm trying to capture a "Number" section and a "Text" section from a string like

    124[HT][HT]In the year 1560, there was ...[CR][HT][HT]somethingt strange going on.[CR][CR]125[HT][HT]The same pattern followed hour after hour.

    I've been trying dozens of different ways in Expresso, but nothing seems to work out.

    (?\d+)\t+(?.*(?=\r{2,}))

    Mostly I get results having the first number in the proper section, but the complete rest of the string in only one "Text" section. What's my stupid error here? Somehow I'm lost in a maze now. Thank you for your time! Mick

    Richard DeemingR 1 Reply Last reply
    0
    • S Sonhospa

      Hello everybody, I've been struggeling with a Regex for hours now, and I hope someone of you can help me out of this. I'm trying to capture a "Number" section and a "Text" section from a string like

      124[HT][HT]In the year 1560, there was ...[CR][HT][HT]somethingt strange going on.[CR][CR]125[HT][HT]The same pattern followed hour after hour.

      I've been trying dozens of different ways in Expresso, but nothing seems to work out.

      (?\d+)\t+(?.*(?=\r{2,}))

      Mostly I get results having the first number in the proper section, but the complete rest of the string in only one "Text" section. What's my stupid error here? Somehow I'm lost in a maze now. Thank you for your time! Mick

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

      This seems to work for your example input:

      (?\d+)\t+(?[^\r\n]+((\r\n|\r|\n)\t+[^\r\n]+)*)


      "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

      S 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        This seems to work for your example input:

        (?\d+)\t+(?[^\r\n]+((\r\n|\r|\n)\t+[^\r\n]+)*)


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

        S Offline
        S Offline
        Sonhospa
        wrote on last edited by
        #3

        Thank you for your great help, Richard - I guess my major misunderstanding was that I interpreted the [CR] as \r only, and not as \r\n? Nevertheless, it seems to work on the original, too. Have a nice evening, Mick

        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