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
1 answer

Extract numbers followed by specific text

I am new to Regex and I am looking to write a Regex to extract any kind of numbers (like 23,23a,24-26) which are immediately followed by a text which is surrounded by !. More explanation: Need to match numbers (simple numbers, the range of numbers…
Mohsen Sichani
  • 1,002
  • 12
  • 33
0
votes
1 answer

How to convert python regex to java regex?

I have some regular expressions in Python which I need to convert to java. I know what I want the regular expression to do, but I just don't know how to convert it. Here is the expression in python: ^172\.(1[6789]|2\d|30|31)\.. I want it to…
makansij
  • 9,303
  • 37
  • 105
  • 183
0
votes
2 answers

how to explode date from this format by regex?

I have some entities such as: یکشبه، 20 فروردین (از 390000 تومان) I want to have the "20 فروردین" at first, then separate them into '20' and 'فروردین'.how to do such thing. speciallym I am wondering for the regex I must use in PHP for the first…
mrmrn
  • 65
  • 4
  • 13
0
votes
2 answers

Regex accept max of alpha and alphanumeric with extra % (without limit)

I dit a lot of search in regex posts but didn't find a solution for what I'm looking for. I have the fellow regex   ([a-zA-Z]{6}[a-zA-Z0-9]{2}([a-zA-Z0-9]{3})?)?   to accept these cases : empty string (6 alpha) + (2 alphanumeric) (6 alpha) + (2…
Samy
  • 121
  • 3
  • 9
0
votes
0 answers

Regx to test space alphanumeric text in Java

Currently I'm using "(?i)lt[\s]*[\d]+" to converts lt34 or Lt34 or lT34 and lt 34 or Lt 34 or lT 34 to Lt34 and Lt 34 respectively using one regex. 34 is just a numeric value and can be anything but the text "lt" is fix with any casing which should…
Raj Bhatia
  • 1,049
  • 4
  • 18
  • 37
0
votes
1 answer

Regex for alphanumeric text in Java

I'm trying write regex to converts lt34 or Lt34 or lT34 and lt 34 or Lt 34 or lT 34 to Lt34 and Lt 34 respectively using one regex. 34 is just a numeric value and can be anything but the text "lt" is fix with any casing which should be converted to…
Raj Bhatia
  • 1,049
  • 4
  • 18
  • 37
0
votes
1 answer

How to put an unmatched result in array using a Regexp?

I want to know if is possible get the unmatched result from a Regexp and put this values in array (just an inversing match). This code handle the solution partially with replace: str = 'Lorem ipsum dolor is amet
Tabares
  • 4,083
  • 5
  • 40
  • 47
0
votes
1 answer

Make this Regex work with negative lookahead

I’m doing an html and bbcode parser. I have this regex that catches repeated groups from the inside-out: $re = '/((?:(?!<\/?b>).)*)<\/b>/is'; But I want to be able to match text or any other attribute inside. I was already…
Vixxs
  • 569
  • 7
  • 21
0
votes
2 answers

Regex to exclude ranges from comma separated list of integers

I want to write a regex that matches a list of numeric values (non-range), given in a comma-separated list, ranges allowed. Empty is not allowed. For ex: List: 1,5-10,20,30,40,50-60 Desired output: 1,20,30,40 I am trying the regex:…
0
votes
2 answers

Regular Expressions - matching words which meet the condition

I have a problem to solve: I need to match every word which has less than 4 characters expect word i,j,k and pom.I made reg exp which finds all words where the size is less than 4 - [a-zA-Z]{1,3} but i dont know how to exclude i,j,k and pom. And i…
anticol
  • 487
  • 1
  • 4
  • 12
0
votes
0 answers

pig script to capture second unique id da12a6b2-70f7-4c07-825a-7d700519f486,633aa5cf-2551-412b-bd98-bd5d9614b288

I have use regex_extract(string, '(([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12})|([a-fA-F0-9]{8}[a-fA-F0-9]{4}[a-fA-F0-9]{4}[a-fA-F0-9]{4}[a-fA-F0-9]{12})), 1) and also string split separated by (,) to capture…
vncg
  • 1
  • 1
0
votes
1 answer

How to use a delimiter with mulitple arguments

I'm trying to parse through a string to get rid of garbage characters, in this example it's things like: &,%,$,#,*,@,etc. But I want to keep spaces and parentheses, right now I'm using a delimiter on a string and just building the string off of…
0
votes
1 answer

Regular expression to consider special characters in a string

The issue is I have to tokenize data into tokens based on spaces at the same time I can't tokenize the data based on special characters. Right now the regex I have is (\w*[-*#+=;:\/,~_ ]*\w+) With this when I process the string 1-CHECK…
0
votes
1 answer

Grep all lines starting without # (hash) or greedy space and # (hash)

I am trying to grep all valid lines of a conf file that do not start with a hash (or) any number of spaces (0 or many) and a hash The regexes below don't seem to work. grep ^[^[[:blank:]]*#] /opt/logstash/logstash.conf grep ^[^[[[:blank:]]*#]]…
deppfx
  • 701
  • 1
  • 10
  • 24
0
votes
1 answer

regex to ignore patterns when after a given characterr

I'm trying to discover a pattern (in a Ruby source code file) but ignore that pattern if found in an inline comment (i.e., after a # character). For instance, given this text foo.bar foo foo::bar # foo.bar foo::bar I'd like the first…
rdnewman
  • 1,379
  • 20
  • 28