Newest regex Questions

Q&A for professional and enthusiast programmers

Not understanding why my PHP program failed to check the phone number?

I do not understand why the code I have written is failing to identify the phone number. Here is the code: <?php $sPattern = "/^ (?: # Area ...

Regular expression to replace a particular text contains Leading and Trailing Spaces [on hold]

How to replace the String with **** If the string has Leading and Trailing Spaces. Example: Sonia as **** and S as **** and S as **** String redActemailBody="Dear Cdr. Sonia S S," Note : The ...

d3 regex or Notepad++ data cleaning

Messing around with various data viz technologies to figure out which one is best for a work-related task, I have found that I need to do some minor data cleaning. I have a column "BookingID", in a ...

Remove \u from string?

I have a few words in a list that are of the type '\uword'. I want to replace the '\u' with an empty string. I looked around on SO but nothing has worked for me so far. I tried converting to a raw ...

Validating String.format-like and printf-like formats on Google Sheet

Suppose there's a Google Sheet populated with different strings in column A among which includes: String.format-like strings: Lorem ipsum {0} {0:dolor|sit} amet {1}. and printf-like strings: Lorem ...

Counting occurrences of a word in a string with Javascript using match

I am trying to count occurrences of each word in longer text using the match method, but instead of result I get only an error: Cannot read property 'length' of null My function looks like this: ...

Read bank debit credit from sms [on hold]

I am able to read SMS from inbox , now i want to read specify message related to bank transactions like Wallnut so please suggest me what can i do for that?

Regex to find words that start or end with a particular letter

Write a function called getWords(sentence, letter) that takes in a sentence and a single letter, and returns a list of the words that start or end with this letter, but not both, regardless of the ...

How to find a text piece followed by a number in Regular Expression [on hold]

I have this text code : primary- {'neu': 1.0, 'compound': 0.0, 'pos': 0.0, 'neg': 0.0} personal- {'neu': 1.0, 'compound': 0.0, 'pos': 0.0, 'neg': 0.0} complete- {'neu': 1.0, 'compound': 0.0, 'pos': 0....

finding xml parts in a sentence with regex

I have such a line: <bpt i="1" type="1" x="1" />und ZF-Getriebe <ept i="1" />TipMatic <ph x="2" type="2" />Lite (&lt;/cf&gt;6AS850, 6AS800, 6AS1000) And I want a regex ...

php regex to select a string based on a start string until space but exclude select string

Supposing we have a string like: text text MinorAlleleCount:G=0.4627/56166 text text text I am using this regex: /(MinorAlleleCount)[^\s]+/ Which returns: MinorAlleleCount:G=0.4627/56166 But I ...

what is the regular expression to match this url?

I am running a scrapy project and i want to extract that text out of the response: >>> response.xpath('/html/body/table[2]/tr/td/table/tr[2]').extract() [u'<tr class="over"onclick="HM.set(...

Regex to extract the US base Mobile/Phone number from a html code

I need PHP base regex to extract all US base phone/mobile numbers from any website's source code, regardless of it's (html) structure. I am working in PHP and I need help in extracting phone numbers ...

IIS Url Rewrite Module - Error with plus add character

I have a problem using + (plus add) character in iis url rewrite module. I need to rewrite: http://www.example.com/search/test1+test2 in http://www.example.com/search/?q=test1+test2 Url rewrite ...

How to capture request and response values in Jmeter and store it in file?

I am using Jmeter as Load Test tool. I passing one parameter through request and in response I am getting only one parameter in result. response. I want to save both request and response in csv file. ...

Replace all the matches in a string that matches array values

I have a string that I am checking for matches using my array and if there are any matches I want to replace those matches with the same words, but just styled red and then return all the string with ...

Use gsub to replace the word 'hi' . (see conditions posted below) - Ruby

For this string: hi i am going on a hike, hi hiiiiiiiiiiiii!. Using gsub how would I replace all instances of hi with bye. The criteria I need to fulfill are as follows: Only find the word 'hi' not ...

Logstash if statement with regex example

Can anyone show me what an if statement with a regex looks like in logstash? My attempts: if [fieldname] =~ /^[0-9]*$/ if [fieldname] =~ "^[0-9]*$" Neither of which work. What I intend to do is ...

finding a variable from string input and extracting it with regex c#

~I have a client which is sending the a message to my server and I am trying to get substrings in order to extract them into variables. I want to use regex for this. Although I have no syntax problems,...

how Replace all b's in a word to “h” if the last letter of the word is an “e” and delete the last “e” with regex [duplicate]

how Replace all b's in a word to "h" if the last letter of the word is an "e" and delete the last "e". example: mbse->mhs s/(\w*)b([e])\1h\2/g replace only b

regex insert a word into a text in alphabetical order

I've implemented a ruby script which supposed to generate & insert a default code pieces into a right places. The problem is that some of those code pieces must respect alphabetical order of ...

Special characters in URL - need to get the capital Ø

I have the following URL: my.site/?param1=Økonomi&param2=Penger I'm using this function to get the parameters value: function getQueryStringValue(url, key) { var params = {}; var ...

Notepad ++: How to remove everything except url?

I have a textdocument with many URLs in it. The URls have many different endings like, .net, .com, .de and so on ... All the URLs have NO http:// oder www. infront. There is many other text in the ...

regex to get emailaddress with / without display name

In my case, content will come it may contain emailaddress in any of the below format. 1. From : dr-dscsda-ds-info@asdf.com 2. From:sadaedf@sdc.sdfds 3. rom: sdcasdc <information@dsf.net> 4. ...

How capture with regex optional values where order doesn't matter?

I need to match an entire string and capture with ruby the value of text, when and image on a string the a string that has any of the following cases: @bot post text:a when:b image:c @bot post text:a ...

Replace non-alphanumeric characters in substring

I am trying to replace any non-alphanumeric characters present in the first part (before the = sign) of a bunch of key value pairs, by a _: Input aa:cc:dd=foo-bar|17657V70YPQOV ee-ff/gg=barFOO ...

Why does RegExp's test return false here? [duplicate]

The following is my code: <html> <body> <script type="text/javascript"> var str = "hello"; var patt1 = new RegExp("\w+"); var result = patt1.test(str); ...

using gregexpr()

I'm trying to use gregexpr() to search through a data.frame. Is there a way to view the results of the gregexpr() search in a data.frame as well? As of now it outputs to a variable. If I could view ...

Regex to capture < not part of a \(…\) block

I'd like to write a regex able to capture the first < character that is not part of a block starting with \( and ending with \). Some examples: foo1<foo2<fooooo3 should return the first <...

how to id in url using php rewrite

Hi friends am using id and post title in url using .htaccess. Am getting output like example.com/videos/1/hello-how-are-you How can I make it as example.com/how-are-you.. Here is my .htaccess code.. ...

Removing quotation marks around text in IntelliJ (with Regex?)

I have a piece of code where I want to remove the quotation marks around property names. // Current format var user = { 'name': 'A', 'loggedIn': true } // Desired format var user = { ...

How to match files with same names and merge them in shell script?

I'm trying to merge several files into a single folder with similar naming pattern regardless to the directory. The file structure is as follows: 20170219-A20-L1-AB1234_S1_R1_001.txt 20170211-B21-...

Regex find symbol, if within ten or so words

Im using Sublime Text as a word processor and would like to use Find to find occurences were I use '?' in back to back sentences or within every ten or twenty words. Can this be done either way? Also ...

Regex for visa cards - exclude results with special symbols in front of the number

I am trying to make regex which can match visa card numbers. I want to catch the number if it has symbols in the end like ", ; space, etc." however i want to skip the number if these symbols are in ...

Reverse proxy in IIS, regex to match everything apart from two URL's..?

I need to have traffic to a domain reverse proxy to a different server. I'm using IIS and URL Rewrite, which is working fine. However, I need to miss out two specific URL's from the reverse proxy (...

regex work on regex101 but doesn't work on javascript

I use a regex convert <a> with images url to <img> var message='<a href="http://example.com/example.jpg" target="_blank" rel="noopener noreferrer">http://example.com/example.jpg&...

Regex: Get parts of url with hyphens in reverse order

I have url like: http://www.example.com/file/golf-background-loop-6863-thumb480x270.jpg Is it possible to capture words sperated by hyphens but in reverse order? thumb480x270.jpg 6863 loop ...

Javascript Regex Fetch all XML from Logfile

i have this Regex String: "<\?xml[^>]*>([\s\S]*?)<Envelope[^>]*>([\s\S]*?)<\/Envelope>" This works by this Log file: http://pastebin.com/Rhcde40q And now i will make the same ...

How to get the attribute with Regex?

the html code: <a class="frame" title="lorem" rel="photo[pp_gal]" href="/img/big.png"> <img alt="lorem" src="/img/small.png"> </a> I can get 「/img/big.png」 like this: $pattern ...

nested brackets in Regex

I'm using regex in java to extract data from user entries like these: String entry1 = "add to xx16,John Doe"; String entry2 = "add to ab20,John Doe;Richard Roe;John Stiles"; They can have multiple ...

File with simple text mixed with html - split on parts

I need to parse some text from some files and split ti by parts, depends on is it simple text part of text or html. Let's say, this is example text This section should include any considerations ...

Why isn't \K supported in javascript regex?

I saw this question Support of \K in regex and was wondering why \K is not supported in javascript? Is there any plan on making it work in the future?

replace all symbols and white spaces with dash using htaccess rewrite

I want to rewrite the URL by replacing spaces and other symbols with dash and removing apostrophe. I am unable to do it. Here is my .htaccess. RewriteEngine On RewriteRule ^videos/([0-9]+)/([a-z\-A-Z]...

preg_match_all dont return result

I want to parse the string to dataset through regex matching in php. here is my code: $string = "?\t\t\t\t\t\t?\t\t\t\t\t\t\t\t\t\t\t\t<?xml version=\"1.0\" encoding=\"UTF-8\"?><documents>...

Regular expression for XML Schema (number then 1 letter)

I have the following requirements for use in XML Schema general format is a number followed by 1 letter should be case-insensitive further restrictions: the valid letters are [smhdw] numbers are ...

My regular expression isn't capturing the groups correctly

I have a string at some point in my code like this: href="http://mywebsite.com/site/link.php?M=191123&N=34&FL=H&L=7" What I need to grab is everything after /site/, so I'm using the ...

Regex/Python missed encompassed pattern

I have tried to research answers to this question online, but nothing seems to describe the problem I have here. If I missed something, please close the question and redirect it to where it has ...

Replace all x after first occurrence

Given the following string: /repos/facebook/react/native. I need to remove /repos/ and then all the slashes after the first one need to be dashes. So for the above example this is the result: ...

Regular Expression in model class in C#

I want to disallowance only list special character ",',<,> in Model Class C#. I use this following code, but it's not work. [RegularExpression("^[^<>'\"]+$", ErrorMessage = "Special ...

How to fix preg_match(): Unknown modifier '{'? [duplicate]

I have a string: $11,950 Some random string $415 and I want to parse the first price information as an integer: 11950 In order to get the first numeric part with the thouand separator, I created a ...
Translating... 0%