Skip to content
Advertisement

Tag: regex

How to set input pattern?

Can anyone please help me to set the correct input pattern for : when input starting digit is 2 then length is 17 digits if starts with 3 then length is 16 digits. For example: when input starts with number 2 then it must be: pattern=”d{4} d{4} d{4} d{4} d{1}” But when input starts with number 3 it must be:

Add domain to src attribute value if a relative path

I have a text variable which contains multiple images with a relative or absolute path. I need to check if the src attribute starts with http or https then ignore it, but in case it starts with / or something like abc/ then prepend a base url. I tried like below: My output is: Issue here: I got 99% result

Pregmatch to get contents between square brackets php

I thought I found a solution here on stack that would work, but I might be going about it wrong: what I am trying to do is create an array where it comes out as: Now this regex is suppose to get me the contents, I think, from the square brackets but all I get is: Which is wrong. I

PHP Regex the nested section based on defined parent

I am trying to match a nested content section of the config based on the alias. I have the base prototype working for matching single aliases over here: https://regex101.com/r/1vwKsx/1 (section correctly matched to: ‘template_path_stack’ =>) HOWEVER, I want to select a section (which is re-used in the file) based on the section container. In the link above, I need to

PHP Preg_match for authorized characters

i’m a noob in regular expressions. Il would like to prevent a form for special characters. The characters auhorized are : I made a preg_match rule that makes problems I know that i should encapsulate special chars but i didn’t know to achieve this. Can you help me please ? Thanks in advance. Answer You can use Note: Using double

Advertisement