w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Regular expression to validate FQDN
Your regex uses a negative lookbehind assertion (?<!-), and those aren't supported by JavaScript. You can rewrite your regex to match exactly the same way without lookbehinds: /(?=^.{1,254}$)(^(?:(?!d|-)[a-z0-9-]{0,62}[a-z0-9].?)+(?:[a-z]{2,})$)/i I'm not so sure if the logic behind the regex really is correct for validating a FQDN, though, but that's a different problem. For example, the optional dot makes the regex susceptible to catastrophic backtracking. This is a good way to crash your browser.

Categories : C#

Regular expression to validate set of special characters
Sounds like you want a pattern like this: ^[w{./\(),'}+:?®©-]+$ Important things to note: ^ and $ match the start and end of the string, respectively, meaning that only these characters are allowed. [ and ] define a character class, which matches any of the characters defined inside the brackets w matches any alphanumeric character or underscore. I omitted T and _ from the character class they are allowed by w. \ is needed to escape the backslash, because that's a special character in regular expressions. - must come at the beginning or end of the character class or else be escaped. Otherwise, it would mean something like a-z any characters between a and z. Many other characters here have special meaning within regular expressions (e.g. ?, +, and ()), but it's not necessary to escap

Categories : Javascript

Regular expression that validate future date
Make 3 fields for day, month and year, like almost any site online. Fill the fields up with values. Then you can populate the year dropdown according to your wishes. And you can simply use the change event to validate the other fields. Plus you can simply use day + month + year, make a date value, and compare with your_date <= new date() Otherwise, you will have to worry about all the different dateformats a string can have, which makes it impossible to validate it. See here: Birthday form using HTML/PHP Something like this: <!doctype html> <html itemscope="itemscope" itemtype="http://schema.org/WebPage"> <head> <title>Hello</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script> <s

Categories : C#

Regular expression to validate FQDN in C# and Javascript
Generally, the Regular Expressions cookbook is a good source of information, written by two regex experts, so you should be starting there. The solution outlined there is not quite adapted to your needs yet (it doesn't validate an entire string but matches substrings, and it doesn't check for the overall length of the string), so we can modify it a little: /^(?=.{1,254}$)((?=[a-z0-9-]{1,63}.)(xn--+)?[a-z0-9]+(-[a-z0-9]+)*.)+[a-z]{2,63}$/i Explanation: ^ # Start of string (?=.{1,254}$) # Assert length of string: 1-254 characters ( # Match the following group (domain name segment): (?=[a-z0-9-]{1,63}.) # Assert length of group: 1-63 characters (xn--+)? # Allow punycode notation (at least two dashes) [a-z0-9]+

Categories : C#

Validate the date format withou using regular expression
The Date constructor expects Y/M/D: Date - Creates JavaScript Date instances which let you work with dates and times. Syntax new Date(); new Date(value); new Date(dateString); new Date(year, month, day [hour, minute, second, millisecond]); If the date is 26/02/2013, you're feeding it with Y/D-1/M: new Date(spl[2],spl[0]-1,spl[1]); Substracting 1 from the day doesn't make any sense so I guess you've just messed the indexes.

Categories : Javascript

How to validate multiple phone number using regular expression
Choose appropriate and suitable regular expression e.g. from here Iterate through your number collection and validate them one by one like: Regex rgx = new Regex(yourPattern, RegexOptions.IgnoreCase); foreach(string num in numbers) { if(rgx.Matches(num )) //do something you need } You also can add RegularExpressionValidator to your phone number column cells in grid and pass it your pattern. Then button click or any event that causes validation will do it for you.

Categories : C#

Blacklist regular expression to validate human name in any language
This is the solution I chose in the end: Note! this is Struts 1.3.1 syntax for a validator mask! ^[^&amp;&gt;&lt;\*?%:!&quot;#$()+,;=@[]{}~^|` /]+$ Disallowing special characters, allowing others. This was considered as a white-list approach, but was neglected as it needed work (adding other languages other than European and Japanese/Chinese): ^[a-zA-Z0-9-'àÀâÂäÄáÁéÉèÈêÊëËìÌîÎïÏòóÒôÔöÖùúÙûÛüÜçÇ’ñß]+|[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+|[々〆〤]+$

Categories : Regex

How to validate a raw Zebra Programming Language (ZPL) file with a regular expression?
I've never heard of one. But it wouldn't be too hard to validate. ZPL is pretty straightforward, especially if there's a very defined set that you send to your printer... The ZPL command characters are ~ for immediate commands an ^ for formatting commands. Label formats must begin with a ^XA and end with a ^XZ. Download commands typically begin with a ~D<something>, like ~DY, ~DG, ~DT, ~DC etc. There are a couple status commands like ~HI and ~HS There may be a couple other edge cases, but these are the most common commands.

Categories : Misc

Regular expression : validate numbers greater than 0, with or without leading zeros
I would not use regexp for that. <?php function tValue($str) { if (intval(substr($str, 1)) !== 0) { // T value is greater than 0 return $str; } else { // convert T<any number of 0> to T<any number-1 of 0>1 return $str[ (strlen($str) - 1) ] = '1'; } } // output: T150 echo tValue('T150'), PHP_EOL; // output: T00001 echo tValue('T00000'), PHP_EOL; // output: T1 echo tValue('T0'), PHP_EOL; // output: T555 echo tValue('T555'), PHP_EOL; Codepad: http://codepad.org/hqZpo8K9

Categories : Regex

Foundation 4:Unable to overwrite its regular expression to validate password
Replacing pattern called password does the trick. Change <script> $(document).foundation(); </script> at the bottom of index.html to the following code: <script> $(document) .foundation() .foundation('abide', { patterns: { password: /^w{3,14}$/, } }); </script> Note that the regex you provided (^[a-zA-Z]w{3,14}$) should be written as /^[a-zA-Z]w{3,14}$/ in JavaScript.

Categories : Validation

MySQL Regular Expression [a-z].[a-z] but not a.m. or p.m
Build your regex step by step: You want everything, except its a "standalone" a.m or p.m: [b-oq-z]{1}.[a-ln-z]{1} matches everything of the format x.y that is not a.# or p.# or #.m However you miss a.a, a.b, a.c ... also. so add that cases: a.[^m] (same for the p-cases: p.[^m]) a.m is valid, when there are chars in front of the a: kra.m, tra.m. Same applies for p.m: erp.m [a-z]{1}[ap].m covers this condtion. Now, we are missing strings, where the second part is longer: a.mod, p.markt: [ap].m[a-z]+ covers that one. Finally just the ones ending with .m but having a different prefix are missing: [b-oq-z]{1}.m This should now cover all possible use Cases. Simple combine the pattern with OR (|) and you are done: ([b-oq-z]{1}.[a-ln-z]{1}|a.[^m]|p.[^m]|[a-z]{1}[ap].m|[ap].m[

Categories : Mysql

Regular expression to validate a string that contains both digit and non-digit characters
You can try using lookaheads: .*(?=.*d)(?=.*D).* But maybe you don't even need a regex? Depending on the language/tool you're using, you might be able to do something like this: Let your input string be s. If s is empty, it is invalid. If the first character of s is a digit: Loop through the other characters of s until you find a non-digit. If you don't find a non-digit, s is invalid. Otherwise: Loop through the other characters of s until you find a digit. If you don't find a digit, s is invalid. If you found the appropriate digit/non-digit, s is valid.

Categories : Regex

Python Regular Expression - Regular Expression that finds one pattern per line?
There's no point loading the whole file into memory to do an re.findall and by doing so you lose the ability to short circuit upon finding the first match import re with open('data.txt') as f: print sum(1 if re.search(r"Line", line) else 0 for line in f) 5

Categories : Python

Regular expression returns empty array in php even though the regular expression is correct
I assume you were trying to do a noncapture group for <price... but you missed the :. Or you should take out the question mark. If the price group is optional, try like the regex below. You should use the following website to help you with regex. I find it extremely helpful. <td>( |s)*?(<span( |s|.)*?</strong>( |s)*?$(<price>)*([0-9.]*).*?)$(.*?)( |s)*?< Edit live on Debuggex In the above example, your first match would have the following captures: 0: "<td><span class="offer"><strong>xscre:<br></strong>$299 xxxxx&x;xx<span class="fineprint_number">2</span></span><br>de&ea;s $399<" 1: "" 2: "<span class="offer"><strong>xscre:<br></strong>$299 xxxxx&x;xx<span clas

Categories : PHP

Regular Expression Error in MySQL Query
Try this as your RegEx pattern: ^[A-z]+[A-Z][A-z]+$ It will match all the examples above (PowerPoint, inCase), and not match 'Alias', one of the examples that you are having trouble with.

Categories : Mysql

how to use regular expression in MySQL where like and in statement in where clause
You can use OR (and group your condition) SELECT date(datetime) as dateonly , sum(CASE message when 'Accepted Images' then 1 else 0 end) as AcceptedIMG, sum(CASE message when 'Rejected Images' then 1 else 0 end) as RejectedIMG, sum(CASE when message like '%Changed to %' then 1 else 0 end) as ChangeIMG FROM customer_1.audit_trail WHERE (message like ('%Changed to %') OR message in ('Accepted Images','Rejected Images')) GROUP BY (dateonly) ORDER BY (dateonly) asc ;

Categories : Mysql

Regular expression excluding subpattern in mysql.log
Seems negative look aheads and behinds could be used to solve your problem. The following regex should do the job in this case. (?<!SHOW )(CREATE TABLE)(?! IF) In this case, it finds any instances of "CREATE TABLE" that is not preceded by "SHOW " or followed by " IF". Note the spaces in the groups. You can then use ^.*(?<!SHOW )(CREATE TABLE)(?! IF).* to match the whole line. You can read up on look aheads and look behinds here.

Categories : Mysql

Change part of record with regular expression in mysql
First, you should remove the domain name from all of your url's. Simple using /images/picture.jpg will allow it to work on all hosts. To replace it globally, I would recommend doing a mysqldump and opening the file in a text editor, replacing the strings, and importing it back into the database. That's assuming you don't have any serialized strings (wordpress) in your database.

Categories : Mysql

MySQL - WHERE IN CLAUSE Regular Expression to Match Phone numbers
You could possible just check if the number you want to test against is at the end of the number in the database, to do this, check out this question on how to use LIKE with multiple values. WHERE phone_number LIKE '%1111122222' will match both 1111122222 and +91111122222

Categories : Mysql

Groovy regular expression - is it different to "normal" regular expressions?
matcher.matches() requires that the whole string match the regular expression, so it will only return true if pageName contains no slashes at all. You probably want to use find() instead of matches(), which returns true if a match is found anywhere in the string. log.info("KPF: pageName is ${pageName} ") def matcher = pageName =~ /([^/]+)(?<=tab[0-9].html$)/ if (matcher.find()) { log.debugEnabled && log.debug("KPF: Filename has tab = ${matcher.group(1)}") } else { log.debugEnabled && log.debug("KPF: Filename does not have tab") } Or indeed just if(matcher) as a Matcher coerces to boolean in Groovy by calling find(). This is done to support syntax like if(pageName =~ /..../) but in your case you need a reference to the actual Matcher in order to extract the p

Categories : Regex

VBA - Like operator vs Regular expression (VBScript Regular Expressions 5.5)
Like is much more limited than regex, but doesn't have the overhead of installing the regex engine. If you click into the word Like in the VB Editor and press F1, the help page describes the entirety of how it works in a few paragraphs. Added: There is so much more than just the options to distinguish between them. Regex has repetition, grouping, back-references. This MSDN page is excellent on VBScript Regex.

Categories : Regex

JS replace regular expression but use part of the expression in the output like a variable
Like so: var input = "[color=blue]"; var output = input.replace(/[color=([a-z]+)]/ig, "<span style="color:$1">"); console.log(output); <!-- results pane console output; see http://meta.stackexchange.com/a/242491 --> <script src="http://gh-canon.github.io/stack-snippet-console/console.min.js"></script> The pertinent bit is that $1 which designates the first capture group.

Categories : Javascript

Can regular expression solve this ? How can we get an array of parameters used in an expression?
If this is the only thing you parse (math operators and capital letters variables), then yes. You can just scan for [A-Z]+ and you'll get your variables. If you need anything more complicated, I'd go with a proper tokeniser. It's not hard to implement and most languages have some kind of support for flex or similar utilities.

Categories : Mysql

regular expression to rewrite 1x as x in mathematical expression
For the example you gave, you could use this: 1([a-z]) And replace all occurrences/matches with $1. Demo. EDIT: There was a misunderstanding with the question, so, a regex that can be used so that 1st is not substituted as well: 1([a-z])(?=[^#]*#[^#]*(?:[^#]*#[^#]*#[^#]*)*$) Demo. (?=[^#]*#[^#]*(?:[^#]*#[^#]*#[^#]*)*$) basically makes sure that there are an odd number of hashes ahead.

Categories : Regex

Validate PHP Expression
Something like this works: $userAnswers["s1"]["q1"] For loop: for ($sNumber = 1; $sNumber <= 2 ; $sNumber+1){ for ($qNumber = 1; $qNumber <= 2 ; $qNumber+1){ $sTemp = "s" + $sNumber; $qTemp = "q" + $qNumber; echo $userAnswers[$sTemp][$qTemp]; } }

Categories : PHP

How can I validate a regular expresion using jQuery Validation plugin?
No need for jQuery. Use the RegExp constructor and catch the exception : try { new RegExp(someString); console.log('good'); } catch (e) { console.log('bad'); } Demonstration (type something in the input to know if it's a well formed regular expression)

Categories : Jquery

validate number with regular exp in javascript not working for one case
You have both d+ and [0-9]{1,2} in the string, which implies there must be at least 2 digits in the string (with an optional decimal in between). If you want the entire decimal part to be optional, just surround it with parentheses and add a ? quantifier: /^-?d+(.[0-9]{1,2})?$/

Categories : Javascript

Reg expression validate / # & characters
You could just try the following: if("/[\/#&]/".test(str) == true) { alert('bad'); return false; } else { alert('good'); } NOTE: I'm not 100% on what characters need to be escaped in JavaScript vs. .NET regular expressions, but basically, I'm saying if your string contains any of the characters , /, # or &, then alert 'bad'.

Categories : Regex

Little regular expression on js
var myRegEx = /<b><font color="#[0-9]{3,6}">(.+)</font></b>[ ]{0,2}<big>(.+)</big>[ ]{0,2}<br>/i; var myString = '<b><font color="#32748">My string:</font></b> <big> My value </big> <br>'; var myResult = myString.match(myRegEx); console.log(myResult[1] + " | " + myResult[2]); RegEx: [0-9] Matches any single character in the range 0-9. {3,6} Matches 3 to 6 of the preceeding token. (.+) Capture group. . Matches any character, except for line breaks if dotall is false. + Matches 1 or more of the preceeding token. Line break character. Carriage return character. [ ] Match any single character in the set. {0,2} Matches 0 to 2 of the preceeding token. Now just apply it in your code. You can test

Categories : Javascript

Regular expression which cannot be used
This is called Catastrophic Backtracking. Your regex has to check to many possibilities, because you are nesting quantifiers: ^s*/*(.*[ ]*)**/ ^^ ^ ^ A better approach would be this: /^s*/*.*?*//gms See it here in action. You need the s option to make the . match the newline, the m option to make the ^ matches the start of he row. .*? is matching as less characters as possible.

Categories : Regex

QTP regular expression
Your .Replace chain does not change the pattern "Millennium [AUT]" which searchs for "Millennium" follwed by " ", followd by one letter out of "A", "U", or "T". Your input "Millennium [AUT]" has a "[" where the pattern expects "A", "U", or "T". So please follow the general rule when asking for solutuions of regexp problems: Give at least one sample input and its expected outcome. Perhaps you meant: >> set r = New RegExp >> r.Pattern = "Millennium [AUT]" >> set mts = r.Execute("Millennium [AUT]") >> WScript.Echo mts.Count >> 1

Categories : Vbscript

Looking for regular expression
Description You could do this by combining some recursive logic around a regex This regex will match open and close brackets nested three layers deep like {a{b{c}}}{{{d}e}f} {((?:{(?:{.*?}|.)*?}|.)*?)} The dotted area is the basic search wherein that search is nested inside itself for as many layers as you need. In the following example I'm simply running the regex against most of your examples. Combine this regex with a foreach loop that would take each Group 1 and capture all non open brackets from the start of the current string ^[^{]*, then recursively feed the rest of the string back through the regex above to capture the value inside the next group of brackets, then capture all the non close brackets from the end of the string [^}]*$. Sample Text {a} {a:b} {a:{b}} {a:{b:c}

Categories : C#

What does this PHP regular expression do?
Looks like it removes '#<!-- START '. $tag . ' -->' and '<!-- END ' . $tag . ' -->' from the text in $this->content, and returns all of the text which was between those comments.

Categories : PHP

How to do this sed regular expression
Use the address part of a sed command to match the region. In this case, starting from a line beginning "SET A" up to a line beginning with SET print those lines that start with a space. $ echo -e "SET A B C D SET E F G H " | sed -n '/^SET A/,/^SET/{ /^ /p }' B C D

Categories : Regex

Regular expression for two or more dot
I don't know if regular expressions are the best way to go about this. http://jsfiddle.net/2KRHh/4/ Or the relevant code: var str = $('#old').val(); var dot = str.indexOf('.'); var newstr = str.substring(0, dot) + '.' + str.substring(dot).replace('.', '', 'g'); console.log(str, newstr); $('#new').val(newstr); The code finds the first dot and saves its position, then replaces the rest of the dots with empty string.

Categories : Javascript

Regular expression in xsd
This is what is called a GUID, commonly used in the "uniqueidentifier" type in SQL. It's a set of 5 groups of hexadecimal digits: a grouping of 8 digits, then a hyphen, then 4 digits, then a hyphen, then 4 digits again, then a hyphen, then 4 digits AGAIN, then a hyphen, then 12 digits. Hexadecimal digits are the numerals 0 through 9 and the letters A through F. Altogether (with hyphens included) this is a 36-digit string. So for example, a valid string might look like this: 3B3AC4DC-3DEB-4241-99BD-5611A68C4CF3

Categories : Regex

Php, Regular expression
This can be simplified with the following pattern. /[link=(https?://)(([a-z0-9]+.?)+)((/[^/]+)+)/?]/i The regex symbol * is not greedy, while + is. Hence, when using the + in the second attempt, all path components are matched and that group is captured; however, in the first attempt with *, since you were only capturing the inner * group with parenthesis, you matched the un-greedy sample of the *, in this case nothing.

Categories : PHP

What do ++ and *+ mean in a regular expression?
++ From what is double plus in regular expressions? That's a Possessive Quantifier. It basically means that if the regex engine fails matching later, it will not go back and try to undo the matches it made here. In most cases, it allows the engine to fail much faster, and can give you some control where you need it - which is very rare for most uses. *+ *+ is the possessive quantifier for the * quantifier.

Categories : PHP

How to set a Regular Expression in PHP
. matches any character, and * means 0..infinity. When using [ and ] you need to escape them. Try this: .*[Some Same Text # ([A-Z]{4})-([0-9]{4})].*

Categories : PHP

Regular Expression - PHP
I'm not sure you could modify your existing regex to match both tables easily, but if you had the second table in a string, you could use: $string = "PLAIN TEXT TABLE DATA HERE"; preg_match('/Golds+(d+.d{2})s+(d+.d{2})/',$string,$matches); $goldBid = $matches[1]; $goldAsk = $matches[2];

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.