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. Find Sequence of alphabets in the string

Find Sequence of alphabets in the string

Scheduled Pinned Locked Moved Regular Expressions
regexhelpquestion
3 Posts 3 Posters 12 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.
  • A Offline
    A Offline
    arisaravanan
    wrote on last edited by
    #1

    I need to find 5 sequence of alphabets has exists in a given string using regular expression. Sequence which should check in any of the form like ABCDE, BCDEF, DEFGH, EFGHI,......,PQRST,...,VWZYZ. Eg. 1) ABCDECODEPROJECT - Match (because "ABCDE" has exists in the string) 2) TESTSTRING - Not Match (because No 5 sequence of alphabets) 3) SAMPLEQRSTUEND - Match (because "QRSTU" has exists in the string) 4) WEBSITELMNOPEND - Match (because "LMNOP" has exists in the string) 5) QUESTIONANSWER - Not Match (because No 5 sequence of alphabets) Can you help me on build regular expression to check all possible combination in alphabets?

    L Richard DeemingR 2 Replies Last reply
    0
    • A arisaravanan

      I need to find 5 sequence of alphabets has exists in a given string using regular expression. Sequence which should check in any of the form like ABCDE, BCDEF, DEFGH, EFGHI,......,PQRST,...,VWZYZ. Eg. 1) ABCDECODEPROJECT - Match (because "ABCDE" has exists in the string) 2) TESTSTRING - Not Match (because No 5 sequence of alphabets) 3) SAMPLEQRSTUEND - Match (because "QRSTU" has exists in the string) 4) WEBSITELMNOPEND - Match (because "LMNOP" has exists in the string) 5) QUESTIONANSWER - Not Match (because No 5 sequence of alphabets) Can you help me on build regular expression to check all possible combination in alphabets?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      RegExr: Learn, Build, & Test RegEx[^]

      1 Reply Last reply
      0
      • A arisaravanan

        I need to find 5 sequence of alphabets has exists in a given string using regular expression. Sequence which should check in any of the form like ABCDE, BCDEF, DEFGH, EFGHI,......,PQRST,...,VWZYZ. Eg. 1) ABCDECODEPROJECT - Match (because "ABCDE" has exists in the string) 2) TESTSTRING - Not Match (because No 5 sequence of alphabets) 3) SAMPLEQRSTUEND - Match (because "QRSTU" has exists in the string) 4) WEBSITELMNOPEND - Match (because "LMNOP" has exists in the string) 5) QUESTIONANSWER - Not Match (because No 5 sequence of alphabets) Can you help me on build regular expression to check all possible combination in alphabets?

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

        This doesn't look like a suitable case for regular expressions. You'd have to build a regex pattern containing every possible sequence to test for, because regex doesn't have a construct for comparing the difference between two characters within a match. It would probably be easier to implement this using a loop. Check each five-character substring from the input to see if it's contained within a string containing the letters in sequence, remembering to account for case and accents if required.


        "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