Regular Expression to match string which doesn't contain substring

Typhoon101

I have a comma separated list as shown below. The list is actually on one line, but I have split it up to demonstrate the syntax and that each single unit contains 5 elements. There is no comma at the end of the list

ro:2581,1309531682152,A,Place,Page,
me:2642,1310989368864,A,Place,Page,
uk:2556,1309267095061,A,Place,Page,
me:2642,1310989380238,D,Place,Page,
me:2642,1334659643627,D,Place,Page,
ro:3562,1378721526696,A,Place,Page,
uk:1319,1309337246675,D,Place,Page,
ro:2581,1379500694666,D,Place,Page,
uk:1319,1309337246675,A,Place,Page

What I am trying to do is remove any unit (full line) that does not begin with uk:. I.e., the results will be:

uk:2556,1309267095061,A,Place,Page,
uk:1319,1309337246675,D,Place,Page,
uk:1319,1309337246675,A,Place,Page

If the string was on separate lines as my example, I could do this relatively easy, but because it is all on one line, I cannot get it to work. Can anyone point me in the right direction?

Thanks

RevanProdigalKnight

This should work:

(uk:\d+,\d+,\w,\w+,\w+)

Demo

It looks for uk: and then it's pretty much comma-counting from there on.

EDIT:

Since OP has now clarified that what they're using can only remove strings:

,?[^u][^k]:\d+,\d+,\w,\w+,\w+

Demo 2

This looks for an optional comma followed by two letters that are not u and not k in that order, then a colon (:), and then the rest of the regex is the same.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Regular Expression Match Doesn't Start With, Contain, Or End With Space And Not Empty String

From Dev

Regular Expression doesn't Match with string

From Java

Regular expression to match a line that doesn't contain a word

From Dev

Regular expression to match text that "doesn't" contain a word?

From Dev

MySQL substring match using regular expression; substring contain 'man' not 'woman'

From Dev

Regular expression to match specified substring to end of string?

From Dev

Regular expression to match exact substring at the beginning of string

From Dev

Regex - Search for text which doesn't contain either of two substrings after another substring match

From Dev

Regular expression match substring

From Dev

Regular Expression to match a pattern that contain some string except some string

From Dev

Regular Expression to match a pattern that contain some string except some string

From Dev

Why my regular expression doesn't match this?

From Dev

Java Regular Expression doesn't find a match

From Dev

How to generate Regular Expression that doesn't contain any white space at all and even at the beginning or the end of the string

From Dev

Python Regular Expression - Match pattern that does not contain a string

From Dev

Maximize substring match in regular expression

From Dev

perl regular expression match substring

From Dev

Regular expression match multiple substring

From Dev

Regular expression to match URL substring

From Dev

a regular expression for substring or exact match

From Dev

Regular expression match multiple substring

From Dev

Can't match string using regular expression with "?"

From Dev

match string with regular expression

From Java

regular expression with cucumber doesn't match the string giving error but would match the same string if the test is written more than once

From Dev

regular expression with cucumber doesn't match the string giving error but would match the same string if the test is written more than once

From Dev

Regular expression which will match if there is no repetition

From Dev

Regular expression which will match if there is no repetition

From Dev

Matching a substring that doesn't contain a certain substring

From Dev

regexp - Match whole string if it doesn't contain another string

Related Related

  1. 1

    Regular Expression Match Doesn't Start With, Contain, Or End With Space And Not Empty String

  2. 2

    Regular Expression doesn't Match with string

  3. 3

    Regular expression to match a line that doesn't contain a word

  4. 4

    Regular expression to match text that "doesn't" contain a word?

  5. 5

    MySQL substring match using regular expression; substring contain 'man' not 'woman'

  6. 6

    Regular expression to match specified substring to end of string?

  7. 7

    Regular expression to match exact substring at the beginning of string

  8. 8

    Regex - Search for text which doesn't contain either of two substrings after another substring match

  9. 9

    Regular expression match substring

  10. 10

    Regular Expression to match a pattern that contain some string except some string

  11. 11

    Regular Expression to match a pattern that contain some string except some string

  12. 12

    Why my regular expression doesn't match this?

  13. 13

    Java Regular Expression doesn't find a match

  14. 14

    How to generate Regular Expression that doesn't contain any white space at all and even at the beginning or the end of the string

  15. 15

    Python Regular Expression - Match pattern that does not contain a string

  16. 16

    Maximize substring match in regular expression

  17. 17

    perl regular expression match substring

  18. 18

    Regular expression match multiple substring

  19. 19

    Regular expression to match URL substring

  20. 20

    a regular expression for substring or exact match

  21. 21

    Regular expression match multiple substring

  22. 22

    Can't match string using regular expression with "?"

  23. 23

    match string with regular expression

  24. 24

    regular expression with cucumber doesn't match the string giving error but would match the same string if the test is written more than once

  25. 25

    regular expression with cucumber doesn't match the string giving error but would match the same string if the test is written more than once

  26. 26

    Regular expression which will match if there is no repetition

  27. 27

    Regular expression which will match if there is no repetition

  28. 28

    Matching a substring that doesn't contain a certain substring

  29. 29

    regexp - Match whole string if it doesn't contain another string

HotTag

Archive