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. Cannot extract end of line data

Cannot extract end of line data

Scheduled Pinned Locked Moved Regular Expressions
regexcsharptestingbeta-testing
2 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.
  • M Offline
    M Offline
    mo1492
    wrote on last edited by
    #1

    Hello, I am new to using Regex and hope someone can help with my expresion. I am using VB.net Regex.Match() to extract info. I cannot figure out how to include the text at the end of a line in my expression. I'm using Expresso for testing my expression. Expression without double quotes: "(.*?)(\\~zs\\~ls)(.*?)(\\~le\\~ks)(.*?)(\\~ke\\~hs)(.*?)(\\~he\\~ze)(.*?)" Source Data1: test \~zs\~lsMt+22:21\~le\~ksMt+22:211\~ke\~hs\~he\~ze end of line Returns: [test \~zs\~lsMt+22:21\~le\~ksMt+22:211\~ke\~hs\~he\~ze] 1: [test ] 2: [\~zs\~ls] 3: [Mt+22:21] 4: [\~le\~ks] 5: [Mt+22:211] 6: [\~ke\~hs] 7: [] 8: [\~he\~ze] 9: [] I do not get a reference to [end of line] Source Data2: \~zs\~lsMark+1:1\~le\~ksMark+1:11\~ke\~hs\~he\~ze some data \~zs\~lsMark+2:1\~le\~ksMark+2:11\~ke\~hs\~he\~ze end of line Returns 2 matches: Match1: [\~zs\~lsMark+1:1\~le\~ksMark+1:11\~ke\~hs\~he\~ze] 1: [] 2: [\~zs\~ls] 3: [Mark+1:1] 4: [\~le\~ks] 5: [Mark+1:11] 6: [\~ke\~hs] 7: [] 8: [\~he\~ze] 9: [] Match2: [ some data \~zs\~lsMark+2:1\~le\~ksMark+2:11\~ke\~hs\~he\~ze] 1: [ some data ] 2: [\~zs\~ls] 3: [Mark+2:1] 4: [\~le\~ks] 5: [Mark+2:11] 6: [\~ke\~hs] 7: [] 8: [\~he\~ze] 9: [] Again, I do not get a reference to [end of line] I've tried end the expression with this (.*$) which works for Source Data 1 but Source data 2 just returns one match with 9:[ some data \~zs....] Can someone help me with extracting the [end of line] text to item 9:? thank you

    J 1 Reply Last reply
    0
    • M mo1492

      Hello, I am new to using Regex and hope someone can help with my expresion. I am using VB.net Regex.Match() to extract info. I cannot figure out how to include the text at the end of a line in my expression. I'm using Expresso for testing my expression. Expression without double quotes: "(.*?)(\\~zs\\~ls)(.*?)(\\~le\\~ks)(.*?)(\\~ke\\~hs)(.*?)(\\~he\\~ze)(.*?)" Source Data1: test \~zs\~lsMt+22:21\~le\~ksMt+22:211\~ke\~hs\~he\~ze end of line Returns: [test \~zs\~lsMt+22:21\~le\~ksMt+22:211\~ke\~hs\~he\~ze] 1: [test ] 2: [\~zs\~ls] 3: [Mt+22:21] 4: [\~le\~ks] 5: [Mt+22:211] 6: [\~ke\~hs] 7: [] 8: [\~he\~ze] 9: [] I do not get a reference to [end of line] Source Data2: \~zs\~lsMark+1:1\~le\~ksMark+1:11\~ke\~hs\~he\~ze some data \~zs\~lsMark+2:1\~le\~ksMark+2:11\~ke\~hs\~he\~ze end of line Returns 2 matches: Match1: [\~zs\~lsMark+1:1\~le\~ksMark+1:11\~ke\~hs\~he\~ze] 1: [] 2: [\~zs\~ls] 3: [Mark+1:1] 4: [\~le\~ks] 5: [Mark+1:11] 6: [\~ke\~hs] 7: [] 8: [\~he\~ze] 9: [] Match2: [ some data \~zs\~lsMark+2:1\~le\~ksMark+2:11\~ke\~hs\~he\~ze] 1: [ some data ] 2: [\~zs\~ls] 3: [Mark+2:1] 4: [\~le\~ks] 5: [Mark+2:11] 6: [\~ke\~hs] 7: [] 8: [\~he\~ze] 9: [] Again, I do not get a reference to [end of line] I've tried end the expression with this (.*$) which works for Source Data 1 but Source data 2 just returns one match with 9:[ some data \~zs....] Can someone help me with extracting the [end of line] text to item 9:? thank you

      J Offline
      J Offline
      jsc42
      wrote on last edited by
      #2

      I'm not a Reg Exp expert, but I recall that '.' matches anything EXCEPT newline so try replacing (.*$) with ((.|\n)*$). You may also need to switch on multiline matching

      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