[Solved] How to select the first number in a string

This substring() expression does what you ask: substring(string, ‘\m\d+\D?*\M’) The regular expression only returns the first match, or NULL if none. \m … beginning of a word\d+ … one or more digits\D? … zero or one non-digits\M … end of word Demo: SELECT string, substring(string, ‘\d+\D?\d*\M’) FROM ( VALUES (‘FLAT 3, thanos house, nw1 6fs’) … Read more

[Solved] Regex for this string format

Seeing as you asked for a C# example, Case Insensitive can be selected as one of the RegexOptions. I assumed the 13 was also meant to be a 2 digit number. using System.Text.RegularExpressions; … Regex regX = new Regex( @”(\d{1,2}):(\d{1,2})-([a-z]{2})-(\d{3,5})”, RegexOptions.IgnoreCase ); if( regX.IsMatch( inputString ) ) { // Matched } … solved Regex for … Read more

[Solved] how to make the width and height x2 using python Regular

Don’t use regular expressions to parse HTML. Use BeautifulSoup >>> from BeautifulSoup import BeautifulSoup >>> ht=”<html><head><title>foo</title></head><body><p>whatever: <img src=”https://stackoverflow.com/questions/5878079/foo/img.png” height=”111″ width=”22″ /></p><ul><li><img src=”foo/img2.png” height=”32″ width=”44″ /></li></ul></body></html>” >>> soup = BeautifulSoup(ht) >>> soup <html><head><title>foo</title></head><body><p>whatever: <img src=”https://stackoverflow.com/questions/5878079/foo/img.png” height=”111″ width=”22″ /></p><ul><li><img src=”foo/img2.png” height=”32″ width=”44″ /></li></ul></body></html> >>> soup.findAll(‘img’) [<img src=”https://stackoverflow.com/questions/5878079/foo/img.png” height=”111″ width=”22″ />, <img src=”foo/img2.png” height=”32″ width=”44″ />] >>> for … Read more

[Solved] Regex to find if a string contains all numbers 0-9 be it in any order [duplicate]

This solution can handle all sorts of strings, not only numeric characters. s1 = ‘ABC0123091274723507156XYZ’ # without 8 s2 = ‘ABC0123091274723507156XYZ8′ len(set(“”.join(re.findall(r'([\d])’, s1)))) == 10 # False len(set(“”.join(re.findall(r'([\d])’, s2)))) == 10 # True How it works: Find all digits in the string with regex findall. Join all matches to one string and get unique characters … Read more

[Solved] Get number from an url in PHP

With regexp: $str=”http:example.com/country/France/45″; preg_match(‘/http:example\.com\/country\/(?P<name>\w+)\/(?P<id>\d+)/’, $str, $matches); print_r($matches); // return array(“name”=>”France”, “id” => 45); 0 solved Get number from an url in PHP

[Solved] RegEx help in JavaScript – extract second match [duplicate]

const regex = /”\w+\|/g; const str = `mmSuggestDeliver(0, new Array(“Name”, “Category”, “Keywords”, “Bias”, “Extension”, “IDs”), new Array(new Array(“Advance Auto Parts Inc.”, “Aktien”, “982516|US00751Y1064|AAP||”, “85”, “”, “Advance_Auto_Parts|982516|1|13715”),new Array(“iShares China Large Cap UCITS ETF”, “Anzeige”, “”, “100”, “”, “http://suggest-suche-A0DK6Z”)), 2, 0);`; let m; while ((m = regex.exec(str)) !== null) { // This is necessary to avoid infinite … Read more

(Solved) Reference – What does this regex mean?

Introduction Regular expressions (regex) are a powerful tool used to match patterns in text. They are used in many programming languages and applications to search, edit, and manipulate text. This article will explain what a regex is and how to interpret a regex. It will also provide an example of a regex and explain what … Read more

(Solved) Reference – What does this regex mean?

The Stack Overflow Regular Expressions FAQ See also a lot of general hints and useful links at the regex tag details page. Online tutorials RegexOne ↪ Regular Expressions Info ↪ Quantifiers Zero-or-more: *:greedy, *?:reluctant, *+:possessive One-or-more: +:greedy, +?:reluctant, ++:possessive ?:optional (zero-or-one) Min/max ranges (all inclusive): {n,m}:between n & m, {n,}:n-or-more, {n}:exactly n Differences between greedy, … Read more

[Solved] RegEx in Java for multiple hits [closed]

Try with JSON library sample code: JSONObject jsonObject = new JSONObject(jsonString); JSONObject innJsonObject = jsonObject.getJSONArray(“entries”).getJSONObject(0); System.out.println(innJsonObject.get(“pageref”)); // page_0 System.out.println(innJsonObject.get(“time”)); // 515 You can try with GSON library as well. sample code: Gson gson = new Gson(); Type type = new TypeToken<Map<String, ArrayList<Map<String, Object>>>>() {}.getType(); Map<String, ArrayList<Map<String, Object>>> data = gson.fromJson(reader, type); Map<String, Object> map = … Read more

[Solved] Regular expression findall python

This looks like a json object but doesn’t have [] around it to make it an actual list. You should be able to convert it into a Python native list of dictionaries and navigate it: import json recipe = json.loads(‘[‘ + your_text + ‘]’) steps = [obj[“text”] for obj in recipe if obj.get(“@type”) == “HowToStep”] … Read more

[Solved] Phone number validation regex for length and numeric values [duplicate]

Try the regular expression ^\\d{10,15}$ Here \d is a predefined character class for digits{10, 15} quantifier stands for a repeat of 10 to 15 times of the previous pattern Ex: String input = “1234567890”; Pattern pattern = Pattern.compile(“^\\d{10,15}$”); if (pattern.matcher(input).find()) { System.out.println(“Valid”); } 0 solved Phone number validation regex for length and numeric values [duplicate]