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. Trying to match a string with many backslashes

Trying to match a string with many backslashes

Scheduled Pinned Locked Moved Regular Expressions
questionregex
2 Posts 2 Posters 6 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.
  • F Offline
    F Offline
    Florian Rammler
    wrote on last edited by
    #1

    Hello there, I have a string that looks like this

    \abc\rvr\sad\dqwdwq Some text \rfdqwdvr\rtgevr\rgwvrr\23rvrv Some text \rffewvr\rfewvr\rvfewrr\rvrwefewv

    I want to match the parts of the string that are connected by the backslashes. I partially achieved this with

    [\\][A-z0-9]+

    but this only matches the first one. How can I match every part with backslashes in this string? Thanks

    Richard DeemingR 1 Reply Last reply
    0
    • F Florian Rammler

      Hello there, I have a string that looks like this

      \abc\rvr\sad\dqwdwq Some text \rfdqwdvr\rtgevr\rgwvrr\23rvrv Some text \rffewvr\rfewvr\rvfewrr\rvrwefewv

      I want to match the parts of the string that are connected by the backslashes. I partially achieved this with

      [\\][A-z0-9]+

      but this only matches the first one. How can I match every part with backslashes in this string? Thanks

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

      Assuming you want to extract three strings:

      • \abc\rvr\sad\dqwdwq
      • \rfdqwdvr\rtgevr\rgwvrr\23rvrv
      • \rffewvr\rfewvr\rvfewrr\rvrwefewv

      Try:

      ([\\][A-Za-z0-9]+)+

      Regexper[^]


      "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

      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