Skip to content
Advertisement

Tag: regex

How do I validate with number and regex in vue js?

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

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 …

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_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