[Solved] Regular Expression to get text from css

If you have CSS styles isolated in a javascript string, you can get the width value with this regex: var re = /\.body\s*\{[^\}]*?width\s*:\s*(.*);/m; var matches = str.match(re); if (matches) { var width = matches[1]; } Test case here: http://jsfiddle.net/jfriend00/jSDeJ/. The height value can be obtained with this regex: \.body\s*\{[^\}]*?height\s*:\s*(.*);/m; If you just want the text … Read more

[Solved] Regex finding duplicate numeric values in a text file

Try this: \b(\d+)\b.*\b\1\b It’ll find a number (thank’s to the word boundaries – \b – only whole numbers) and then match anything .* until the number is found again (\1 back reference). If the repeating one isn’t found it doesn’t match. See it here at regex101. Regards 4 solved Regex finding duplicate numeric values in … Read more

[Solved] Replace words in a string one by one using C#

You can query the source string with a help of Linq while matching whole word of interest with a help of regular expressions: using System.Linq; using System.Text.RegularExpressions; … string source = @”This is example 1, this is example 2, that is example 3″; string word = “is”; string[] result = Regex .Matches(source, $@”\b{Regex.Escape(word)}\b”, RegexOptions.IgnoreCase) .Cast<Match>() … Read more

[Solved] Filter out records that are not in this date format oracle

You can use an inline function to check if the date is valid. Like this: WITH FUNCTION is_valid_date (date_str_i VARCHAR2, format_i VARCHAR2) RETURN VARCHAR2 /* check if date is valid */ AS l_dummy_dt DATE; BEGIN SELECT TO_DATE(date_str_i,format_i) INTO l_dummy_dt FROM DUAL; RETURN ‘Y’; EXCEPTION WHEN OTHERS THEN RETURN ‘N’; END; dates AS ( SELECT ‘0201-05-31 … Read more

[Solved] get elements by attribute value

You can use XPath with an expression like //Book[ListOfBookUser/BookUser]: var xmlMarkup = `<ListOfBook> <Book> <Id>ACIA-11QWTKX</Id> <ListOfBookUser recordcount=”0″ lastpage=”true”> </ListOfBookUser> </Book> <Book> <Id>ACIA-ANC0CC</Id> <ListOfBookUser recordcount=”1″ lastpage=”true”> <BookUser> <BookId>ACIA-ANC0CC</BookId> <BookName>TKSP_GLOBAL</BookName> </BookUser> </ListOfBookUser> </Book> <Book> <Id>ACIA-ANC0CF</Id> <ListOfBookUser recordcount=”0″ lastpage=”true”> </ListOfBookUser> </Book> <Book> <Id>ACIA-EUMCH5</Id> <ListOfBookUser recordcount=”1″ lastpage=”true”> <BookUser> <BookId>ACIA-EUMCH5</BookId> <BookName>TKSP_MADRID_CENTRO_SUR</BookName> </BookUser> </ListOfBookUser> </Book> </ListOfBook>`; var xmlDoc = new DOMParser().parseFromString(xmlMarkup, … Read more

[Solved] Using Python Regex to Simplify Latex Fractions

Here is a regex that should work. Note that I made a change in your LaTeX expression because I think there was an error (* sign). astr=”\frac{(\ChebyU{\ell}@{x})^2}{\frac{\pi}{2}}” import re pat = re.compile(‘\\frac\{(.*?)\}\{\\frac\{(.*?)\}\{(.*?)\}\}’) match = pat.match(astr) if match: expr=”\\frac{{{0}*{2}}}{{{1}}}”.format(*match.groups()) print expr NB: I did not include the spaces in your original expression. 0 solved Using Python … Read more

[Solved] Find Text between Html Tags [closed]

Use the HTML Agility Pack, which includes a DOM parser – it is never worth writing your own parser or RegExs for HTML. http://www.nuget.org/packages/HtmlAgilityPack In the example below, you can see how easy it is to select an element using XPATH. Because the values you want aren’t actually in an element, I’m using text() to … Read more

[Solved] Regular Expression for Employee ID with some restrictions [closed]

mlorbetske’s regex can be rewritten a bit to remove the use of conditional regex. I also remove the redundant 0-9 from the regex, since it has been covered by \d. ^[a-zA-Z\d](?:[a-zA-Z\d]|(?<![._/\\\-])[._/\\\-]){0,49}$ The portion (?:[a-zA-Z\d]|(?<![._/\\\-])[._/\\\-]) matches alphanumeric character, OR special character ., _, /, \, – if the character preceding it is not a special character … Read more

[Solved] Regex to match all strings with a trust list only

I would use the following regex to match one two or three seperated by ; , or space /(^\s*(one|two|three)\s*$|(^\s*(one|two|three)([ ,;]+(one|two|three))+\s*$))/gm Test more here: https://regex101.com/r/ETN5go/4 3 solved Regex to match all strings with a trust list only

[Solved] How to Parse using Regex in C# [closed]

Maybe this will help: string input =@”””POST /trusted HTTP/1.1″” “”000.00.00.0″” 200 9 “”42″” 123456 A3rTW6ecEIcBACvMEbAACAJA”; var r = Regex.Matches( input, “((\”[^\”]+\”)|([^\” ]+))” ); foreach (var s in r) { System.Console.WriteLine(s); } System.Console.ReadLine(); 0 solved How to Parse using Regex in C# [closed]

[Solved] Javascript string.match with specific prefix and text after [closed]

You can use /specialPrefix:\s*(\[.*?\])/ let inputs = [“any string before specialPrefix: [‘content1’, ‘content2’] and any other text after”,”any string before specialPrefix:[‘content1’, ‘content2’] and any other text after”,”any string before specialPrefix: ‘content1’, ‘content2’ and any other text after”]; var result = inputs.map(str => (/specialPrefix:\s*(\[.*?\])/.exec(str) || [])[1]); console.log(result); solved Javascript string.match with specific prefix and text after … Read more

[Solved] c++ Check if string is valid Integer or decimal (both negative and positive cases)

The answer was a simple Regex: bool regexmatch(string s){ regex e (“[-+]?([0-9]*\.[0-9]+|[0-9]+)”); if (regex_match (s,e)) return true; return false; } It will return true on integers (i.e. 56, -34) and floating point numbers (i.e. 6.78, -34.23, 0.6) as expected. 3 solved c++ Check if string is valid Integer or decimal (both negative and positive cases)

[Solved] Ruby regex method

Use regex /r\d+=\d+/: “http://test.com?t&r12=1&r122=1&r1=1&r124=1”.scan(/r\d+=\d+/) # => [“r12=1”, “r122=1”, “r1=1”, “r124=1”] “http://test.com?t&r12=1&r124=1”.scan(/r\d+=\d+/) # => [“r12=1”, “r124=1”] You can use join to get a string output. Here: “http://test.com?t&r12=1&r122=1&r1=1&r124=1”.scan(/r\d+=\d+/).join(‘,’) # => “r12=1,r122=1,r1=1,r124=1” Update If the URL contains other parameters that may include r in end, the regex can be made stricter: a = [] “http://test.com?r1=2&r12=1&r122=1&r1=1&r124=1&ar1=2&tr2=3&xy4=5”.scan(/(&|\?)(r+\d+=\d+)/) {|x,y| a << … Read more

[Solved] Does there exist an algorithm for iterating through all strings that conform to a particular regex?

Let’s say the domain is as following String domain[] = { a, b, .., z, A, B, .. Z, 0, 1, 2, .. 9 }; Let’s say the password size is 8 ArrayList allCombinations = getAllPossibleStrings2(domain,8); This is going to generate SIZE(domain) * LENGTH number of combinations, which is in this example (26+26+10)^8 = 62^8 … Read more