I have to validate textbox accepting only numeric value and number must start with 7 or 8 or 9 (regex). I have already done maxlength, minlength and required rule. Which are perfectly working fine. But I don’t know how to validate with only accepts number and regex. I have tried some of the syntaxes but not working. Answer The validation
Tag: regex
Return a substring of a string if exists
I need to extract console platform from the description of products in CSV file. I used regex to match all the console brands that are included in the list. This is for WP All-Import plugin PHP …
Replace pairs of symbols in chat text with html tags to style as bold, italic, and strikethrough
I am trying to make a whatsapp style text post. When user create text like this: then this text is automatically changing like this Hi how are you where are you I know i can do it with php regex like this: The example is for bold text: But there is a problem it should be remove * when text
Regex letters are not allowed when they should be?
My and my group are trying to create a simple PHP code editor that also executes the code without the use of a library. We know the risks that come with eval(), but since it’s all running on a local server it shouldn’t be a problem. The Regex part is definitely the problem since we have no clue how that
how to “regex” all options in select menu
The sample data is this: With the following code I can capture only one data: How can I capture all data to “SIZExSIZE” (e.g 50×80 or 150×230) and “Stock: [0-9]” until the last Select. Answer Just change (.*) by ([sS]*?)</select> so the complete regexp would be: <select name=”ctl00$ContentPlaceHolder1$UrunListesi$ctrl([0-9]{1,2})$StokBoyut” id=”ctl00_ContentPlaceHolder1_UrunListesi_ctrl([0-9]{1,2})_StokBoyut”>([sS]*?)</select> Demo . does not match new lines so you may use
preg_split – split by white space and by chosen character but keep the character in array
So i have this problem, i want to split a string by a pattern that contains white space( ) and comma (,). I managed to split my string by that pattern but the problem is that i want to keep that comma in array. Here is my string: Here is how i split it: Here is the array that i’m
PHP: Replace the content between two characters, in multiple occurrences
I’m trying to replace the contents between some “special” characters, in each of their occurrences. For example, let’s say i have that string:
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)
Anonymize IPv4 and IPv6 addresses with PHP preg_replace?
I needed to anonymize IPv4 and IPv6 addresses so I coded this crude solution: It works fine with full length IPv4 and IPv6 addresses like 207.142.131.005 2001:0db8:0000:08d3:0000:8a2e:0070:7344 but not with abbreviated addresses like 207.142.131.5 2001:0db8::8d3::8a2e:7:7344 I wonder if there is an elegant solution with preg_replace and some regular expression magic? Answer No conditional is necessary. You can write two patterns
Change iframe src with regex
I’m trying to change the src attribute of an iframe from http to https. For example, my string is:
Some random text