Questions tagged [regex-negation]

Regex-negation is an operation performed on a character class that complements its pattern. The result is the character class matching anything not in its class.

Regular Expression negation is typically used to search for patterns that are not desired.

The regular expression language provides some features to handle this, notably negative lookahead/lookbehind, see this tutorial for details.

1926 questions
0
votes
3 answers

Regexp in Grok sometimes catches a value sometimes not

I've a code in grok, which captures messages, and if they meet a given criteria, they get a tag. My problem is, that sometimes this filter works while testing, and sometimes does not. The regexp in question is the…
Letokteren
  • 749
  • 1
  • 15
  • 28
0
votes
1 answer

Fixing Negative Assertion for end of string

I am trying to accept a capture group only if the pattern matches and there is not a specific word before the end of the group. I've tried a # of approaches and none seem to work, clearly I'm not getting the…
user3649739
  • 1,829
  • 2
  • 18
  • 28
0
votes
2 answers

Regex for matching string not ending or containing file extensions

In a Java application, I need to write a String containing a regex for URIs, so that the URI does not contains character sequences like .js?, .css? and .jpg?, but are also not ending with .js, .css and .jpg I made the…
mat_boy
  • 12,998
  • 22
  • 72
  • 116
0
votes
1 answer

Find all CR or LF (simply enter) between double quotes in regex

My input: 2,india,"i join today,and please guide me,thank you",+91547854221 My requirement is find all CR or LF ( simply enter ) between "....." in single shot. Required Output : 2,india,"i join today,and please guide me,thank…
kiran
  • 83
  • 1
  • 1
  • 9
0
votes
2 answers

regex - Find all strings not matching a pattern

We receive a file daily with thousands of lines of data. Occasionally, a few lines will be messed up, causing an automated process to fail. When this happens, it can be difficult to find the errors. I'd like to use a regular expression to find…
Cyan02
  • 3
  • 2
0
votes
0 answers

MongoDB regex does not match string between 2 pipes

so i want the regex match this type of elements, this regex is created in javascript. I assume in mongo you need \\ to escape instead of one element: toto|titi|tata|tete if my value is tete or titi or tata or tete it return false if my value to or…
0
votes
3 answers

Java regex replacing all the characters except few combination of characters

Input String : NNULL(EUR,VALUE)+SOMESTR Expected output:NNULL(X,X)+X Expression tried: String str = "NNULL(EUR,VALUE)+SOMESTR"; str=str.replaceAll("[^(NNULL)\\+,]+","X"); Output getting: NNULL(XUX,XLUX)+X
Puneet
  • 753
  • 3
  • 9
  • 24
0
votes
1 answer

Reverse reading via regex or grabbing last match with no tail

I need to grab the 2 character letter and numbers after that: What I want is: AB 12 CD-12345-67 -> CD-12345 AB12 CD 12345-67 -> CD 12345 AB-12CD12345-6 -> CD12345 ABC1234556 -> no match, as I look for 2 character letter and numbers after…
0
votes
2 answers

Regex match for a specific pattern excluding a specific pattern

I have sample string as : '&label=20:01:27&tooltext=abc\&|\|cba&value=6|59|58|89&color=ff0000|00ffff' '&label=20:01:27&tooltext=abc\&|\|cba&value=6|59|58|89' My objective is to select the text from 'tooltext=' till the first occurrence of '&'…
kingshuk basak
  • 423
  • 2
  • 8
0
votes
2 answers

Regular expression to match "wap" not preceeded by "html"

I'm using NGINX to segment mobile traffic between a mobile WAP/HTML site. Looks like the best way to do this is going to be to check the UA's preference for content by checking the HTTP Accept Header. A preference for WAP is indicated by the…
jbox
  • 131
  • 2
  • 7
0
votes
1 answer

JavaScript Regex to avoid certain pattern in textbox

I have a validation to be done. The below pattern(post Man/PostMan/post Man etc) should not be allowed in my text box. [P|p](OST|ost).*\s*[M|m][a|A][N|n]\s*(\d.)* I have to add a few more validations to the same input such as: Allow: Alphabets,…
user3223509
  • 139
  • 1
  • 1
  • 12
0
votes
1 answer

Python RegEx Replace - Inverting the Search removing too much

Working in Python 2.7. I'm attempting to remove from a string all things not databases and tablename combinations. I'm using regex for this, and unintentionally removing all the whitespace (which I need to keep to separate the values) s = "replace…
Lee_Str
  • 3,266
  • 2
  • 21
  • 32
0
votes
0 answers

Making negate work after character-class with MySql Rexep

I am trying to capture records with specific terms followed by digits. I used both: Select * from Table where Field Regexp 'Term [0-9]{1,6}' and Select * from Table where Field Regex 'Term [[:digit:]]' However the issue is I grab ordinal #s…
user3649739
  • 1,829
  • 2
  • 18
  • 28
0
votes
2 answers

How to speed up regex search in R?

I have a code matrix<-outer(df$text, df1$regexp, str_count) df with more than 1000 text's, each about 1500 symbols and df1 with 500 regex-negation expressions like (?
stack user
  • 88
  • 1
  • 1
  • 8
0
votes
3 answers

Can Anyone Complete this regex?

KELECTRIC.BNK.20160526 compare above expression and take 8 digits after 2nd full stop and total of 22 characters, below expression is working fine till 2nd full stop but not taking number after full stop ^(KELECTRIC)\.(BNK)+\.$