[Solved] python Regular expression [closed]

I think this is what you’re after: file = open(“demo.txt”,”r”) text = file.read() def find(info,text): match = re.findall(info + “+\w+\d+”,text) if match: print(match) else: print(“Not found!”) # This is how you call the function find(“whatever info is supposed to be”,text) 3 solved python Regular expression [closed]

[Solved] remove white space before comma

You need to use: $(‘[data-title=”Score”]’).text().replace(/ \,/g, ‘,’); //or .replace(” ,”, ‘,’); for single occurence if you want to replace the text : $(‘[data-title=”Score”]’).text(function( index,text ) { return text.replace(/ \,/g, ‘,’); //or .replace(” ,”, ‘,’); for single occurence }); Working Demo 3 solved remove white space before comma

[Solved] How to gather the url text inside HTML-div via regular expression?

You should use DOMDocument and DOMXPath or something like that, but if you want it done with regexp, for your given html this should do the trick: <?php $html_code=”<a href=”https://stackoverflow.com/napolnye-pokrytiya/” class=”category_cart”> <div class=”category_cart__container”> <div style=”background-image: url(\”/media/filer_public/b6/49/b6491a4d-5c0d-4a0f-aa9c-b32ea39912c6/category-2.jpg\’)” class=”category_cart__thumbnail”></div> <div class=”category_cart__content”> <p class=”category_cart__title”>Напольные покрытия</p> </div> </div> </a> <a href=”http://stackoverflow.com/oboi/” class=”category_cart”> <div class=”category_cart__container”> <div style=”background-image: url(\’/media/filer_public/93/65/9365c3bc-8649-4d9d-932e-144f16ed535c/category-3.jpg\’)” class=”category_cart__thumbnail”></div> <div … Read more

[Solved] How to create a regexpression for a name with just letters and one “-” i java? [closed]

Not that this is the best idea to verify names. But assuming you’ve settled your requirements, then you can use next example: if(input.matches(“[a-zA-Z]+(\\-[a-zA-Z]+)?”)) { //OK } else { //Invalid } Several examples I’ve tested using this page: String matches? qwe Yes qwe- No qwe-qwe Yes qwe-qwe- No qw2e-qwe2 No qwe-qwe-qwe No solved How to create … Read more

[Solved] Replace “-” with capital Letters [closed]

public class Test { public static void main(String[] args) { String input = “eye-of-tiger”; String modified = dashToUpperCase(input); System.out.println(modified); } private static String dashToUpperCase(String input) { StringBuilder result = new StringBuilder(); boolean toUpper = false; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == ‘-‘) { toUpper … Read more

[Solved] How to select a date using regex [closed]

The .* will match everything after the :, including the space and the time. To get just the date, be more specific than a wildcard that matches any character. Use this pattern: #(\d{2}/\d{2}/\d{4})# Capture group #1 will contain the date. You tagged it as only regex and not php, but in PHP that would be: … Read more

[Solved] Unable to get data between multiple keyword using powershell

The problem with your script is here : Where-Object {$_ -match ‘(?is)(?<=\bNAME1\b).*?(?=\bNAME2\b|\bNAME3\b|NAME4|NAME5|NAME6\b)’} This doesn’t mean “keep the matches”, but “if there is a match, keep the entire string”. Here is another way to do what you want : $text = Get-Content .\withoutStar.txt $regex = “(?is)(?<=\bNAME1\b).*?(?=\bNAME[2-6]\b)” Set-Content .\AllfunctionGroup.txt -Value “” (Select-String -Pattern $regex -Input $text -AllMatches).Matches … Read more

[Solved] some characters that need to use ‘\’ before them to delete [closed]

Which characters need ‘\’ before them to delete from a text ? Characters you must and must not escape depends on the regular expression indication you’re working with. For the most part the following are characters that need escaped outside of character classes [] are: .^$*+?()[{\| And the characters ^-]\ need escaped inside character classes. … Read more