I've searched high and low, and cannot seem to find anything, so finally deciding to beg for help here in the hopes anyone here can give me a hint!

My current task is to search a list of strings, for strings that contain characters in sequence. I'm struggling to find an efficient method, and thought maybe Regular Expressions might be able to pull it off?

So for example, I have the following data:

hello world

Of those, ultimately, I only want "abcdefgh", "zyxwv" and "123456789" because the ENTIRE string contains characters in sequence. The first string I don't need, since only a part of it is in sequence (1234), not the entire string.

I haven't been able to find anything for regular expressions that seems like this is possible?

  • Maybe search harder :-) stackoverflow.com/questions/15476488/… – uSlackr Jan 26 '17 at 22:07
  • Yes it's possible, but it's kind of hard to tell you how to do it without knowing which language the regex is going to be written in. – DrZoo Jan 26 '17 at 22:17
  • 1
    @uSlackr: Thanks, I searched, that one never came up ... – Ditto Jan 27 '17 at 0:18
  • @DrZoo actually, eventually it's aimed for Oracle believe it or not :) I'm currently using a more complex method (of course) .. but was curious if RegEx could possibly be an option. The link by uSlackr seems to indicate "no, it's not easy - possible yes - but not easy" .. and I'm ok with that. It confirms what I thought - I just wanted to ensure I wasn't missing something else :) – Ditto Jan 27 '17 at 0:19

This can be done but it isn't an "elegant" regex. Essentially you give regex a long list of patterns. More in this Stack Overflow answer

| improve this answer | |
  • 1
    Thanks, I agree, it's as I figured, and understood ... I'll give this time just in case somebody comes up with some epiphany .. but I'll accept this answer in due time :) – Ditto Jan 27 '17 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.