I use an SMS API to send confirmation code to phone. Its parameters requires me to set the visitors phone number format into international, for example +9912345678 instead of 012 345 678. Is there a php class (without Composer) that would do it for me (could not find anything so far on GG), considering I know user’s both country (from
Tag: regex
wp_nav_menu filter, removing a specific link
I’m trying to remove a specific link from my wordpress menu: <li class="ubermenu-item ubermenu-item-type-post_type ubermenu-item-object-page ubermenu-item-1 ubermenu-item-level-0 ubermenu-column …
preg_replace get each two characters from a word
Actually I’m trying to come up with a way of getting a string like “GEWO” out of the “Get Word” by using preg_replace function. The thing is there also can be a strings like “Get”, or “Get Word And another Word” so I have to get the proper string respectively. Thanks! Answer Use this: ouput: GEWOANANWO
How can I filter by “ends with” using PHPUnit’s –filter option?
I’m trying to filter a PHPUnit test suite. When I try to filter by test name using –filter, the tests that exactly match the specified string are executed, but so are any tests that begin with the string. eg. If I have two tests, testExample and testExampleTwo, the following runs both tests: How can I get phpunit to stick to
preg_match accented characters
I have an issue using preg_match with php. I want my users to fill the Name field with only valid characters. Ex: no numbers or special chars. My site will eventually be bilingual but most of my visitors are french Canadians I prefer utf-8 for my encoding. So at the top of my document i have this tag : I
Correct way to add comments to a Regular Expression in PHP
I’m trying to add comments to make a regexp clearer But i get the warning Warning: preg_replace(): Unknown modifier ‘/’ in on line 280 How should i comment it? Answer This may not be the cleanest approach, but you could enclose each section in quotes and concatenate them. Something like this should work: Alternatively I found this in PHP docs.
Insert spaces into a string at each change of character
I’m trying to create a string with a blank space between all “different characters, for example: I tried the following recursive function, not knowing if this is the best way because I couldn’t find any build-in function in PHP for this. For some reason, this function seems to iterate infinitely, and I can’t figure out why. Where do I go
PHP – Why am I being warned that my regular expression is too large?
I would like to use a regular expression to validate user input. I want to allow any combination of letters, numbers, spaces, commas, apostrophes, periods, exclamation marks, and question marks, but I also want to limit the input to 4000 characters. I have come up with the following regular expression to achieve this: /^([a-z]|[0-9]| |,|’|.|!|?){1,4000}$/i. However, when I attempt to
Preg_match string inside curly braces tags
I’d like to grab a string between tags. My tags will be with curly braces. So far I have found #<s*?$tagnameb[^>]*>(.*?)</$tagnameb[^>]*>#s This one matches tags with angle brackets <>. I couldn’t figure out how to make it look for curly braces. Eventually I would like to parse whole page and grab all matches and build an array with strings. This
How to replace custom html tag with html code in php
This is my scenario: In a custom CMS developed in PHP, I need to parse HTML string searching some custom tags to replace them with some HTML code. Here is an example for clarifying: I need to find the custom tags and replace them with the template of the item, as a result: This would be very helpful, but I