Skip to content

Tag: regex

Regex to select a certain word followed by a integer or decimal?

I need a regular expression to detect the phrase Figure 1.5: in a given string. Also, I intend on using this expression in a PHP preg_replace() function. Here are some more examples: …are given. Figure 2.1: shows that… …are given. Figure 3: shows that… …are given. Figure 1.16: sh…

Regex to find and expression and insert into the middle

I’ll be brief as I can. I’m trying to use preg_replace’s regex to find a digit, but I want to non destructively edit the string. an example: (albeit this is an approximation due to data protection) Any help would be gratefully received Answer Use Replace with <hr/>$0. See regex proof. …

Pull values from string to assign into an array

I’ve got a project where I’m pulling data from SOQL using salesforce’s RestAPI. I’ve cleaned up the response and this is what I’m currently working with: I’m working in PHP and I’d like to build an array based off this data. For example: Anyone have suggestions for th…

Compare and trim binary/unicoded string to normal string?

I am using below mysql query to check which records vary from the trimmed value Above query returns binary value and trimmed value as shown below. Result of mysql query: Highlighted values in above image show that binary value vary from trimmed value. I tried below 2 things: calculating length of both binary …

ignoring img tags while searching for urls in string

I have the following code in which I am replacing urls with hyperlinked anchor tags, But I want to ignore all img tags while searching for urls, I have no idea how can I go for it. Answer As per @Biesor and @Nigel Ren I came up with this, For the time being I am using this till some better

Regex with avoidation of markdown

Pattern is : /(?:https?://)?(?:[^.]+.)?momento360.com/e/(.*)?/i This regex pattern returns the remaining part of the URL after the website. But now I want to ignore the string that is in [click here](…) Markdown Answer You can use See the regex demo. Here, [click here](http[^()]*)(*SKIP)(*F) – mat…

split each HTML tag into new line using PHP

I’m going to split each HTML tag into a new line. This is my source: And I’m gonna have it like this: or like this: And this is what I’ve done: and this is the output with put each “>” in a separate line (array member). Answer Instead of using a regex and splitting your source…