Questions tagged [regex-greedy]

The greedy regex property causes the regex engine to repeat a regex token as often as possible. Only if that causes the entire regex to fail, give up the last iteration, and proceed with the remainder of the regex. The greedy regex tokens are `+`, `*`, `?` and the repetition using curly braces.

Example of Greediness

Using a regex to match an HTML tag the regular expression does not need to exclude any invalid use of sharp brackets. An HTML tag will be anything between sharp brackets.

If the test string is the following:

This is a <EM>first</EM> test.

With the <.+> patterh a expected match would be <EM> and when continuing after </EM>. But he regex will match <EM>first</EM>.

The reason is that the plus is a greedy token.

969 questions
-3
votes
1 answer

I need to use RegEx to find a speciffic word in HTML page?

I'm trying to extract a specific word (that might change) which comes after a permanent expression. I want to extract the name Taldor in this code:

Company Name

-3
votes
1 answer

regex expression to parse logs

Hello hackers wonder if anyone can help out i need to match all types of logs with pattern any suggestions on how to match full object in {} ? Sample [1517725731.300][DEBUG]: DEVTOOLS EVENT Runtime.consoleAPICalled { "args": [ { …
Alexander
  • 17
  • 1
  • 1
  • 3
-3
votes
1 answer

regular expression matchinf for first occurrence

I have a text's case 1 :push ($arr, $var1); case 2 : push $arr, $var1, $var2; case 3 push ($arr, $var1, $var2); I need to grep out capture it as $1=push ( and $2 as $arr and $3 as , $var1, $var2); for case 3 i tried it as …
questionar
  • 274
  • 2
  • 18
-3
votes
1 answer

How to apply regex in javascript to obtain single quote from json

sample: "{ ' foo ' : ' bar ' baz ' bob ' , 'foo2':'Barr ' s' }" I want single quotes to be filtered, so that i can escape ' with \' and process.
Siva
  • 25
  • 6
-3
votes
1 answer

Regex for multi line search that should select text "abc" which comes before the text "xyz" and should not select anything except "abc"

Regex for multi line search that should select text "abc" which comes before the text "xyz" and should not select anything except "abc" suppose if the text is as below, aaaabbbb abc abc lmn xyz the regex should match only the text abc…
-3
votes
4 answers

regex - how do i pull a string between exatcly (n) white spaces?

Im having some problems pulling numbers(54878, 45666, 23331,003455) from a list of strings, I have a list of strings like the following (about 2700+): ["011 54878 20000 0.00", " 45666 134 2.75", " 23331 0 …
MaxKedem
  • 41
  • 1
  • 1
  • 9
-3
votes
1 answer

Regular Expression specific to a particular message pattern with mandatory elements

As I'm pretty new to Regular Expression, I'm looking for a regular expression which will validate whether entire string is separated by | and there will be values with $ followed by an integer. Valid Values:…
Renju
  • 55
  • 1
  • 5
-3
votes
2 answers

URL Validation REGEX - URL valid with http://, www. , https://www. , http://www. only

I want an regular expression which excepts above url and the words can be in capital letters also. I am not getting any regular expression. This code is not working properly. var url="www.google"; var…
anu
  • 11
  • 2
-3
votes
1 answer

Replacing a dynamic url with text?

I need to replace the below url (including img tags) with text. I am not very good with regex... However, as the date will change its not only about copy and replace infortunately.
-4
votes
2 answers

find first matches character in regular expression

i have a string that i want to find "a" character and first "c" character and replace with "*" character, but regular expression find all "a" and "c" character i don't know how do it. here my code: var pattern=/[a][c]/g; //here my pattern var…
user12026752
-4
votes
3 answers

regex: between square brackets exists one string and not exists another

My regex question is, Between square brackets, the text begins with the string 'Started' and after it, but between the brackets not exists string 'Continue'
L. Kvri
  • 1,456
  • 4
  • 23
  • 41
-4
votes
1 answer

c# regrex for a string repeated multiple times

I would like to have a regualr expression for the string where output would be like: CP_RENOUNCEABLE CP_RIGHTS_OFFER_TYP CP_SELLER_FEED_SOURCE CP_SELLER_ID_BB_GLOBAL CP_PX CP_RATIO CP_RECLASS_TYP I tried using regex with string pattern =…
SQLSERVERDAWG
  • 57
  • 2
  • 10
-4
votes
2 answers

RegEx for failing subdomains

Basically, I would like to check a valid URL that does not have subdomain on it. I can't seem to figure out the correct regex for it. Example of URLs that SHOULD…
franco
  • 667
  • 4
  • 7
  • 20
-4
votes
1 answer

regexp ignore some context after matching

i want to solve regular expression in javascript for: ignore } character wrapped context by quote. but must match } character out of quote. example: "The sentense { he said 'hello, {somebody}', she said 'hi, {somebody}' } got a something." result: {…
zkyz
  • 3
  • 3
-4
votes
4 answers

Too greedy Regex problem

I need to parse string that looks like in example below: Regex TitleRegex = new Regex(@"[A-Z].* - ([0-9].*) [A-Z]"); var match = TitleRegex.Match("Chapter - 1 The Brown Fox"); Console.WriteLine(match.Groups[1].Value); What I want is to extract a…
levanovd
  • 4,095
  • 6
  • 37
  • 56
1 2 3
64
65