Unmatch when Slash( / ) is followed by Underscore( _ ) or hyphen( – )

I am constructing an ID, in Javascript, which doesn’t allow special character and uppercase letter. We could have / _ – in the ID, but the it should not begin with these. hello correct helloWorld incorrect 123hello correct hello/world correct -hello incorrect _hello incorrect $hello incorrect /hello incorrect hello$ incorrect hello_world correct hello-world correct hello-world/apple… Read More Unmatch when Slash( / ) is followed by Underscore( _ ) or hyphen( – )

Regex match after numbers before double underscore

I would like to extract substrings that start after a number and before a double underscore. Below you see two test strings and the expected output after ->. ‘1234514 TEST STRING__blabla3452b’ -> ‘TEST STRING’ ‘16275653 TEST_STRING__bl67abla3452b’ -> ‘TEST_STRING’ The regex I came up with so far: (?:^|\n)\d+([^__]+) only returns the first but not the second… Read More Regex match after numbers before double underscore

Regex to match strings between quotes

I try to create a regular expression to match strings between quotes but it seem’s not working. My RegExp: \[shortanalytics\snumber=[0-9]+\stoptext="[A-Za-z]+"\sbottomtext="[A-Za-z]+"\sicon=[A-Za-z]+\] Text to match: [shortanalytics number=60 toptext="super test" bottomtext="test 2" icon=add] >Solution : You can try using the following one: "([^"]+)" Explanation: ": quote ([^"]+): any character other than quote ": quote This will match any… Read More Regex to match strings between quotes

Regex to match multiple numbers within string

I have a regex that looks like this to extract order numbers from columns: df["Orders"].str.extract(‘([0-9]{9,10}[/+ #_;.-]?)’) The orders column can look like this: 12 123456789 1234567890 123456789/1234567890 123456789/1/123456789 123456789+1234567890 The resulting new column in the dataframe after the regex should look like this: NaN 123456789 1234567890 123456789/1234567890 123456789/123456789 123456789+1234567890 However, with my current regex I’m… Read More Regex to match multiple numbers within string

re.sub() wildcard

Am I doing something incorrectly with wildcards? I am trying to trim anything that follows " > " but it is only trimming the " > " import re noteIndex = "5/10/22, 14:20 > Mr Frank" subStrip = ‘ > *’ noteStrip = noteIndex.replace(", " , "/") noteID = re.sub(subStrip , "" , noteStrip) print(noteID)… Read More re.sub() wildcard

Is there a cleaner way to extract a substring from a string in PHP using RegEx?

I have a function that is getting a string of "lead time" in WooCommerce. An example would be:Available! Estimated Lead Time: 2-3 Weeks. I want to get the 2-3 Weeks. So far, I’ve been able to do it with the following function: function display_lead_time_notice_card() { global $product; //Get Stock Status $in_stock = $product->get_availability()[‘class’]; //If In… Read More Is there a cleaner way to extract a substring from a string in PHP using RegEx?