Skip to content
Advertisement

Tag: preg-match

Regex for splitting apparel sizes

I have the following input (only for example, real input contains much more crazy data) and want to split it by separators like / or , but keep pairs of values. This should be done only, if separator does not occur multiple times, so the result should look like: What I have so far is But this fails for 40/42/44/46/48

When do I need u-modifier in PHP regex?

I know, that PHP PCRE functions treat strings as byte sequences, so many sites suggest to use /u modifier for handling input and regex as UTF-8. But, do I really need this always? My tests show, that this flag makes no difference, when I don’t use escape sequences or dot or something like this. For example preg_match(‘/^[da-f]{40}$/’, $string); to check

preg_match include string with unlimit occurence

I trying to create preg_match function with a pattern to validate the future string with unlimit occurence. This is my function like this: One occurrence must respect the following format any charchters between two parentheses: (mystring123/). The whole of string ($arg) is a collection of these occurrences. For example 1-This string is valid (AAA/)(BBB/)(cc). 2-this string is not valid (AAA/)xxxx(BBB/)(cc)

PHP How to add plus (+) character before double quotes and words without double quotes in string [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 6 years ago. Improve this question I have below string: And I want to add plus (+) character before

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

I can’t get preg_match to test if the entire string matches the regex

I’m using this regular expression to test if a username is valid: [A-Za-z0-9 _]{3,12} when I test it for matches in a text editor with the string test’ing, it highlights ‘test’ and ‘ing’, but when I use the following code in PHP: if(!preg_match(‘/[A-Za-z0-9 _]{3,12}/’, $content) where $content is test’ing and it should return FALSE, it still returns true. Is there

Validate UK short (outward) postcode

I’m using this validator: From this link. But I want to be able to validate postcodes like ME20 and TN10 instead of a full blown ME20 4RN, TN0 4RN. This is the part of the postcode known as the ‘outward code’. Can someone help me out with the regex? Answer you can use my updated regex to solve you problem

Advertisement