[Solved] Regular expression php for a pro [closed]

Here is my version: function test($v) { if (preg_match(‘/^\\[(“number”)(,”number”)*\\]$/’, $v)) echo ‘ok<br>’; else echo ‘fail<br>’; } or if “number” is really digits, this one: function test($v) { if (preg_match(‘/^\\[(“[0-9]+”)(,”[0-9]+”)*\\]$/’, $v)) echo ‘ok<br>’; else echo ‘fail<br>’; } NOTE – only positive naturals are accepted, need to change to negative and decimal/floating numbers 1 solved Regular expression … Read more

[Solved] How do I remove all strings containing digits before “hs” like “18hs” from a list of strings? [closed]

>>> import re >>> words = [“hello”, “18hs”, “18aaa”, “21hr”] >>> [w for w in words if not re.match(r’\d+h’, w)] [‘hello’, ’18aaa’] This loops over the list and keeps the items that don’t match the regex \d+h, which means “one or more digits followed by an h”. If you need to keep strings like 7hg, … Read more

[Solved] How to write Regexp for checking parts of url?

Your question is very unclear. As of your comment, I understand it like that (seems to be the case, so here the same as in the comments above also as an answer): The beginning of the string needs to be https:// followed by some text and then domain.com? If so, you can use https:\/\/(?:.*?\.)?domain\.com.* Here … Read more

[Solved] Regex for Javascript for [quote] [closed]

I recommend you step back from what you’re doing and take 30 minutes or so to read up on regular expressions. This is a fairly trivial application of them. In JavaScript, you can do it like this: var match, value; match = /\[quote#([^\]]+)\]/.exec(yourString); value = match && match[1]; 5 solved Regex for Javascript for [quote] … Read more

[Solved] create a regular expression of a specific sentence [closed]

If you’re just asking for a way to parse the variable bits from this kind of text, it’s quite easy: See here: http://tinyurl.com/qjdaj9w var exp = new Regex(@”angle\(Vector\((.*?),(.*?)\),Vector\((.*?),(.*?)\),(.*?),(.*?)\)”); var match = exp.Match(“angle(Vector(JointA,jointB),Vector(JointA,jointB),minValue,maxValue)”); var jointA1 = match.Groups[0]; var jointB1 = match.Groups[1]; var jointA2 = match.Groups[2]; var jointB2 = match.Groups[3]; var max = match.Groups[4]; var min = … Read more

[Solved] Extract Substrings using regex Java [closed]

This regex will match all the data that are you asking: \(DT\s\w+.{3}NN\s\w+\) Where \(DT\s\w+ match the Determiner, thr white space and the string, .{3} match ) ( and NN\s\w+\) match the Noun, singular or mass. Using regexpal match the data but if you want use it in Java code you need to escape the charactes … Read more

[Solved] about complicated RegExp [closed]

If you need to match string including only \w, – or . and not starting with ., then try this: /^(?!\.)[\w.-]+$/ Details: ^ – search from start of string (?!\.) – don’t match if there is . symbol at this position [\w.-]+ – match to more than 1 symbols from \w.- set $ – match … Read more

[Solved] Add html after variable

A trivial regex that works unless > characters might occur somewhere within the <body> tag itself: Search for <body[^>]*> and replace the match with $0<mynewtag>: $result = preg_replace(‘/<body[^>]*>/’, ‘$0<mynewtag>’, $subject); Test it live on regex101.com. 0 solved Add html after variable

[Solved] Regex: How to match instances of text, including spaces and new lines? [closed]

You’re asking to match any number of lines of text, followed by only 1 additional newline at the end, simply: ^(.+\n)+\n(?!\n) will do what you’d like. Example here: https://regex101.com/r/Hy3buP/1 Explanation: ^ – Assert position at start of string (.+\n)+ – Match any positive number of lines of text ending in newline \n – Match the … Read more

[Solved] Filter input amount at specific points in regex? [closed]

[A-Za-z0-9]{1,254} Indicates , any character of: ‘A’ to ‘Z’, ‘a’ to ‘z’, ‘0’ to ‘9’ (between 1 and 254 times (matching the most amount possible)), Edit: If you need @ at the end try with the regex [A-Za-z0-9]{1,254}@ 1 solved Filter input amount at specific points in regex? [closed]