Skip to content
Advertisement

Tag: regex

PHP Regex Match Specific Pattern between Quotes

I have strings with the following pattern: adfadfadfadfadfadfafdadfa”externalId”:”UCEjBDKfrqQI4TgzT9YLNT8g”afadfadfafadfdaffzfzfzxf Basically, I need to find “externalId” and extract it’s value in between the quotes that follow. The length of the value can change so it needs to be everything inside the two quotes. In this case the desired outcome is to return: Here’s what I have so far: I tried Advanced HTML

Regex match specific string without other string

So I’ve made this regex: to match only the first of the following two sentences: discount of €50,20 on these items This item on sale now for €30,20 As you might’ve noticed already, I’d like the amount in the 2nd sentence not to be matched because it’s not the discount amount. But I’m quite unsure how to find this in

Placing a dash for each identical word (regex, php)

Please tell me if it is possible to make a search for all identical words through rejax and insert a dash between them until such a word is no longer the next in the sentence. Example here: https://regex101.com/r/1GQiQ8/2 My regex: Sample text: How it should be: How does it work now: Answer You can use Replace with -. See the

Get attribute value and replace tag PHP

Consider the following HTML… And this array… How would I replace the var tags where I am able to use the data-mach attribute as the key for replacing the data? The end result would be… Hello Elon, your email is elon@spacex.com I know I can do… But how do I make the “replaced” value use the “data-mach” attribute? Answer Regex

PHP preg_split split by group 1

I have these inputs: I want to split them by the first parentheses, the output i want: I tried these but not working correctly : But it splits every space with parentheses and returns five items rather two. Answer You can use See the PHP demo. See the regex demo. The preg_split third $limit argument set to 2 makes it

Need assistance with regular expression [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 1 year ago. Improve this question I have many strings enclosed within a function called trans. In some places it could be trans(‘Hello’) or trans(“Hello”) I

Regex discard catch between strings

I wrote this regex: (?<![.#])bMY_STRINGb(?![#])(?!.*(;video)) With the intention to search for a string not containing . or # preceding it, and no # succeeding, it also checks if at the ending does not contain the word ;video. I’m trying now in how I could also check for if between the found string exist a comma before it, and the text

Advertisement