I want to replace the occurrences of the pattern “binary_function([x,y])” with substring “XY” in a given string. I have it working with the following code: However, I also want it to replace “binary_function([x1,y1])” with substring “X1Y1”, and any length of the arguments inside the square brackets e.g. [x11,y12], [var1,var2], etc. I tried this: but it did not work. Can anyone
Tag: regex
Java Regex vs. PHP, Dangling meta character ‘?’
I’m tagging this with PHP even though it’s a Java question. The regex is copied from a PHP source so I’m hoping some PHPers can help with the question. I decided to build a simple spam filter, just …
regex to detect trailing comma and/or space separated numbers [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 need a regex to detect and match some values like that: but values like following, are not allowed: One
Regex pluck parts too, not whole string
This is my input content: and this is regex example: This is the $matches content: Not bad, but I’d like somehow to pick “add_to_cart” and “product_name” as well. I can do it with explode() function, but wonder if there is a way to do this by regex only once. Also, I wonder if it is possible to have ‘target’ these
Regex for Group Links For WhatsApp URL [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about programming within the scope defined in the help center. Closed 1 year ago. Improve this question I am using the following regex for validating Group Links For WhatsApp url’s. I want the regex to support the following
PHP regular expression start and end with given number [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 2 years ago. Improve this question I have a string like this 202009170439051466017152d0bd457094b54f32eb029c4e9111725 I need to select the 1466017152 from that. (start with 146 and ending
PHP 7.4 PCRE2 newline character warning
Been testing a codebase migration from 7.3 to 7.4, and the only thing that affected us is the PCRE update under PHP. Currently this regex: /(>)([Rsvh]*)((&|#)?nbsp;|(&|#)nbsp)*([Rsvh]*)(<)/ Throws a nasty warning: Compilation failed: escape sequence is invalid in character class at offset 7 And indeed, if I remove the R, the warning disappears, but of course the behaviour changes. I have
PHP preg_match_all – extract content from pattern in different order
I’m cleaning up some wordpress short codes in my code and I’m looking for a solution that would extract the right values no matter the order of the values. Example: If I want to extract my_label, my_url and other_value, I would use the following structure: The problem is that I sometimes have a different order like this: My previous preg_match_all
Regex to extract (austrian) street housenumber/stairs/floor/door
I need to extract the housenumber with all the different constellations in austria: | Street name | housenumber | stairs | floor | door | | ———————————…
How to exclude single-lettered title case words in a string?
I have a database table that stores wishes from users. From that, I’d like to extract any title case words that they have submitted. I was able to obtain this output, however it includes single-…