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
2 answers

Struggling with negative lookahead in a regex

I humbly request for some guidance on using multiple negative lookaheads in a regex. I currently have a string that matches up against 2 regular expressions. String: Armadale Joe Bloggs 22-333-222 20001 Whitfords to…
sdpl.cs
  • 13
  • 1
  • 5
0
votes
3 answers

How can I create a regex to match the inner-most match or work from right-to-left?

I'm trying to match the strings for image references but am picking up a little too much when there's an expression involved. In this example http://www.regexr.com/3b3ub, you'll see I'm doing good on the 1st and 3rd matches but I'm getting too much…
billy
  • 1,435
  • 1
  • 11
  • 11
0
votes
1 answer

Regex to match everything in a string except "
", "
", "
"

I want a regex to match everything in a string except "
", "
", "
". Reason being, i want to put string in a container and want "" tags to execute and display other tags as they are written by the user. For example: String--> "I have…
Mahima
  • 489
  • 1
  • 5
  • 17
0
votes
1 answer

Matching commas between HTML tags in a CSV

I've got a CSV which I'm trying to reformat which contains some HTML, but the HTML has commas in it, which is making life difficult. How can I use regex to replace the commas within the HTML tags with HTML Entities. Thus far I've tried things like…
FaCE
  • 188
  • 9
0
votes
1 answer

How to stop Repeating characters at 2? REGEX

(\b(?:([A-Za-z0-9])(?!\2{2}))+\b) actually does. but when a string like "pepper" comes, it doesnt hit. wen there are continuos 3 repeating characters, it hits. ?? Any clue?
0
votes
2 answers

Incorporate regex quantifier into brackets

I am trying to incorporate the following negative lookahead regex ^(?!\*\*) into the following regex ^([a-z]:)?(\\[^<>:"/\\|?;,$=%@~]+)+\\?$ Basically, I don't want two consecutive asterisks (**) to appear anywhere in the file path. How do I…
madridista
  • 79
  • 12
0
votes
3 answers

Removing character from regexp class in R

Edit: Changing the whole question to make it clearer. Can I remove a single character from one of the regular expression classes in R (such as [:alnum:])? For example, match all punctuation ([:punct:]) except the _ character. I am trying the replace…
mattdevlin
  • 1,045
  • 2
  • 10
  • 17
0
votes
4 answers

Regex for URL to sites

I have two URLs with the patterns: 1.http://localhost:9001/f/ 2.http://localhost:9001/flight/ I have a site filter which redirects to the respective sites if the regex matches. I tried the following regex patterns for the 2 URLs…
phani sekhar
  • 107
  • 1
  • 1
  • 13
0
votes
3 answers

How to create regex for accepting only numbers and not anything else(not even spaces)?

I have seen the question Regex for accepting only numbers . But this is not what I want. My regex is accept anything except number and replace it with null. Like /[^0-9]/g then replace with null its working for all, except for spaces. The regex is…
Tehreem
  • 476
  • 9
  • 23
0
votes
3 answers

Regular Expression: Match lines not starting with 32 spaces in Notedpad++

In Notepad++, I'm trying to match lines not starting with 32 consecutive spaces. I already have the regex that matches lines starting with 32 consecutive spaces: ^ {32}.*$ I tried with ^[^ {32}].*$ and ^[^( {32})].*$ with the same wrong result,…
cprcrack
  • 17,118
  • 7
  • 88
  • 91
0
votes
1 answer

Problems to negate regex pattern

I have several regex patterns and i have to negate them all, so i am trying to build somo generic regex negate, something like /^(anypattern)/ but I am having troubles.. for example, I have this text:…
leandromoh
  • 139
  • 6
0
votes
0 answers

replace json array with object using regex

with asp.net API i get json array from API service.But there is deserialization problems.For example response sometimes array for Supplier sometimes it returns one item(just object not object array) my response string contains that object array …
user1688401
  • 1,851
  • 8
  • 47
  • 83
0
votes
1 answer

JavaScript regex pattern for numbers only and ignore backslash

I am very new to regex and in researching for an answer found many cryptic answers, I hope someone here can lend a hand. I am validating an input field for MM/DD and am limiting the input to numbers only with ng-pattern="/^0|[1-9]\d*$/" The format…
Charles Smith
  • 3,201
  • 4
  • 36
  • 80
0
votes
1 answer

Python Regex/Beautiful Soup Wild Card

Sorry if this has been answered elsewhere, I couldn't find exactly how to do this and I am not the most experienced with regex of BeautifulSoup. Basically, I have these lines of code. finder = re.compile('div_\w\w\w_basic') for soup_ in…
qwertylpc
  • 2,016
  • 7
  • 24
  • 34
0
votes
2 answers

Regex: Match from second occurence

I`d created a regex for matching nth occurence in the string: ^(?:[^-]*-){2}([^-].*) However, testing it in the regex tool did not get 100% matching solution: For example: origin: ANIMAL - Animal Rage XL Pre-Workout Grape of Wrath - 151…
AlexBerd
  • 1,368
  • 2
  • 18
  • 39
1 2 3
99
100