Skip to content
Advertisement

Tag: regex

PHP: Explode comma outside of brackets

Below is a string I’ve tried to explode only on comma’s outside of the first set of brackets. Wheat Flour (2%) [Wheat Flour, Wheat Gluten, Calcium Carbonate, Iron, Niacin (B3), Thiamin (B1), Ascorbic Acid], Water, Yeast, Salt, Vegetable Oils (Palm, Rapeseed, oils (sunflower, rapeseed)), Soya Flour 1st Attempt Which returns: 2nd Attempt Returns: The first attempt is the closest I’ve

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: shows that… …are given. Figure 0.4 shows that… …are given. figure 5.1:

regex riddle. want results: ‘onetwothree’, ‘onetwo’, ‘twothree’ but NOT ‘two’. Positive lookahead maybe?. For currency extraction

confused with some basic regex logic. Using simple example: I want regex to catch: but NOT and catching in groups (one)(two)(three). I know I can use positive lookahead on ‘two’ so that it is only preceded by ‘one’: but then I cannot get the ‘twothree’ result The real world need is for currency: so I want to get these results:

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. EXPLANATION Code snippet:

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 this? I’ve tried doing some regex but I don’t think it’s the right

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 and trimmed column but it is same

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) – matches [click here](…) substring and skips this match, starting the search for a new match at the

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 into an array, you

Advertisement