[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Regular Expressions

A regular expression ("regex") is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. "find and replace"-like operations. Regular expression processors are found in several search engines, search and replace dialogs of several word processors and text editors, and in the command lines of text processing utilities, such as sed and AWK. Many programming languages provide regular expression capabilities, some built-in, for example Perl, JavaScript, Ruby, AWK, and Tcl, and others via a standard library, for example .NET languages, Java, Python and C++ (since C++11). Most other languages offer regular expressions via a library.

Share tech news, updates, or what's on your mind.

Sign up to Post

I need help writing a regular expression that can be used to extract 4 names from a text similar to the 2 examples pasted below. The first 3 names appear separated by commas, following the "Decided:.*Before" pattern. The last name appears after any number of characters, following the 3 names, but on a different line, that would also have the keyword "judge" (case insensitive) in it.

In the example 1 below, the first 3 names are:
DYK
SCHALL
REYNA

The fourth name is:
SCHALL

In the example 2, the first 3 names are:
MOORE, WALLACH, and STOLL.

The fourth name is:
WALLACH

Thank you, experts!


EXAMPLE 1
 Office, Patent Trial and Appeal Board in Nos.\nIPR2015-00343,     IPR2015-00345,     IPR2015-00347,\nIPR2015-00348.\n               ______________________\n\n              Decided: March 26, 2018\n              ______________________\n\n   DAN L. BAGATELL, Perkins Coie LLP, Hanover, NH,\nargued for appellant.   Also represented by ROBERT\nSWANSON, Washington, DC; ANDREW GISH, DOUGLAS R.\nNEMEC, Skadden, Arps, Slate, Meagher & Flom LLP, New\nYork, NY.\n\n   GREGORY S. DOVEL, Dovel & Luner, LLP, Santa\nMonica, CA, argued for appellee. Also represented by\nSEAN LUNER, MATTHAEUS MARTINO-WEINHARDT; JUNG\n\f2              GOOGLE LLC   v. NETWORK-1 TECHNOLOGIES, INC.\n\n\n\nSUK HAHM, CHARLES R. MACEDO, Amster Rothstein &\nEbenstein LLP, New York, NY.\n                

Open in new window

0
Microsoft Azure 2017
LVL 12
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Hello,

I've many connection strings in web.config which I need to replace with different values. Please find below three types i.e. name = "DBString1", "DBString2" & "DBString3"Please note, "DBString2"


<add name="DBString1" connectionString="server=servername;database=DBName;user id=userid;password=password;Application Name=Web:TestApp" providerName="System.Data.SqlClient"/>


<add name="DBString2" connectionString="Data Source=servername2;Initial Catalog=DBName2;uid=userid2;pwd=password2;Application Name=Web:TestApp" providerName="System.Data.SqlClient"/>


<add name="DBString3" connectionString="server=servername3;database=DBName3;user id=userid3;password=password3;Application Name=Web:TestApp" providerName="System.Data.SqlClient"/>

Best Regards
0
Hi Folks,

Could you assist me to generate regular expression to change web.config connection string?
For example, below "DBString", I need to make change in server, user id, password like servername, userid password values respectively
<add name="DBString" connectionString="server=servername;database=DBName;user id=userid;password=password;Application Name=Web:TestApp" providerName="System.Data.SqlClient"/>

Open in new window


Could you assist into it?

Best Regards
0
Need help with regular expression to fin a words after a match string.   I need to find all the word after "KW".    For example;

Wiring Config
-------------------
54KW208V             --->  Need to find 208V
64kw
300KW c               ----->  Need to find  c
0
I'm trying to get the op numbers from the following filename strings using RexEx which the pattern will be used in VS2017 using the C# language for developing a Windows Form Application. In this application, we are filtering filenames in a datagridview by Op number when searching through a folder directory and all its subdirectories. I'm having an issue trying to get the regex to work on the tester websites I have tried. These are regxr.com and regexstorm.net/tester

Filename1: C-2590-3 REV-B OP#50.pcl
Filename 2: C-2590-3 REV-B OP#50-59.pcl
Filename 3: C-2590-3 REV-B OP#50-59-90.pcl
Filename 4: C-2590-3 REV-B OP#50-59-90-70(Flip).pcl
Filename 5: C-2590-3 REV-B OP#50-59-90 (Flip)60-90.pcl

The text I need to capture is :

Filename 1 Results: 50
Filename 2 Results: 50-59
Filename 3 Results: 50-59-90
Filename 4 Results: 50-59-90-70
Filename 5 Results: 50-59-90 60-90

This is what I have tried on the regexr.com tester:

(?<=\043)\d{2}|(?<=\043)\d{2}.\d{2}|(?<=\043)\d{2}.\d{2}.\d{2}

(?<=#)\d{2,}|(?<=#)\d{2,}.\d{2,}|(?<=#)\d{2,}.\d{2,}.\d{2,}

and I keep getting stuck because it will only show me the 1st two digits "50"

I'm not real familiar with Regex and I thought I should get some help because I'm missing something And don't know what that might be.

Can anyone help with this? Here is a screenshot of the form application running.

Tesa File Search - Screenshot1
0
Hi, everybody!

I have an annoying challenge where I have Excel data like

"Projection packages range from $200-$350" or
"$31.22 per user ($1,561 flat rate) Dedicated Bandwidth for 50" or
"12% added to F&B, 10% added to all meeting room rental charges"

in cells in worksheets containing property information, and I'd like to try to create a UDF that will pull out the 1st instance of a number out of the string in these cells (or, alternatively, if a UDF is not possible, just a regular sub).

Thus, something like "Projection packages range from $200-$350" would convert to 200,
"$31.22 per user ($1,561 flat rate) Dedicated Bandwidth for 50" would convert to 31.22
"12% added to F&B, 10% added to all meeting room rental charges" would convert to 12

Thanks for any help you can provide.

Best,

-doctornick0
0
Need help with a regular expression.   Just need a REGX to match on multiple words.  I need to find words "Gas, Propane (LP)" or "Gas, Natural".  

Source File - Fuel Type     Regex Match Results
--------------------------------     ----------------------------
Gas, Propane (LP)             Gas, Propane (LP)
Gas, Natural                      Gas, Natural
Electric
Gas                                      
Gas, Propane                    Gas, Propane
123  
Propane
Gas Natural                      Gas Natural  
Gas Propane (LP)            Gas Propane (LP)

thanks,
0
I have a table in a DB with a general text field which contains HTML formatted text. I need to parse the content of such a field, find all the "img" tags and perform 2 operations (only for "img" tags):

1) Remove completely the "style" attribute (if there is one).
2) Add a class="img-responsive" attribute.

For example, a simple string to be parse can be as follows:

<div>
<p>This is some text</p>
<img src="http://www.mywebsite.com/myImage.jpg" alt = "" style="width:600px; height: 400px;"/>
</div>

Open in new window


Or, something more complex:

<p style="margin: 0px 0px 10px; background: white; font-size: 14.6667px; font-family: Calibri, sans-serif;"><span style="font-size: 14pt; font-family: Georgia, serif; color: #404040;">
<img src="http://www.mywebsite.com/myImage.jpg" alt="" style="width:600px; height: 898px;" />
<br /></span></p>  

Open in new window


In both cases, the "img" tag should result in:

<img src="http://www.mywebsite.com/myImage.jpg" alt="" class="img-responsive" />

Open in new window


I know that one option is to use regular expressions but I do not have any experience with them. I will be using C# to perform this task.
I will very much appreciate your help.

Respectfully,
Jorge Maldonado
0
What would the JS regex be to test if a string had "business" and optional "qa" followed by a period? So both the below would pass?

businessqa.bank.com
business.bank.com
1
I need some regex help. I am currently using the following regex "^(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z])(?=.*[^a-zA-Z])\S{8,20}$" (without the quotes) to validate a password that would require an upper, lower and non-alpha character. I need regex to meet the following criteria:

The password contains characters from three of the following categories:

Uppercase letters
Lowercase letters
Base 10 digits (0 through 9)
Non-alphanumeric characters (special characters): (~!@#$%^&*_-+=`|\(){}[]:;"'<>,.?/) Currency symbols such as the Euro or British Pound are not counted as special characters for this policy setting.
Any Unicode character that is categorized as an alphabetic character but is not uppercase or lowercase. This includes Unicode characters from Asian languages.
0
Exploring SQL Server 2016: Fundamentals
LVL 12
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Dear Experts

I am trying to find software - optimally free, which would allow me to play with regular expression in a way, that from current set of found capturing groups I would be able to setup new text, copy it and paste where I need.

Simply example:

I have 2 lines of text taken from somewhere (copied) and pasted into Regular expression software:
2018-09-18 Hash XY
2019-01-17 Hash AB


In search field I would search for (\d\d\d\d)-(\d\d)-(\d\d)

And somewhere in 3rd window I wanted to enter %3-%2-%1

Which would give me
18-09-2018
17-01-2019

Do you have any idea?

Thanks

Vladimir
1
Hi there, I need a regex expression to extract a uk phone number from a string.
This is with a view to detecting phone numbers in paragraphs of text.
There are plenty of examples out there to verify UK phone numbers as being a regex match but I cannot find anything which will do so returning the match from within a string.
Uk phone numbers are 10 or 11  numbers long with a 0 at the beginning.  

This regex is an example of a regex which matches a phone number, but cannot handle leading or trailing text.  Can somebody help perhaps in modifying it so it can still pick out the numbers in a string whilst ignoring leading/trailing text.  

^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$

Open in new window


Thanks,
0
How to have textbox regular expression validation on asp.net?


I will have to allow 3 digits and units in the text box. Decimal units should not exceed more than 2 units.

How to handle that?
0
I'm looking for a  Javascript regx that will detect a-z (case insensitive)  or 09 as a group and then a hyphen followed by any group  of a-z or 09  etc. Always will start/end with (a-z or 09) For example:

a12dd3-23-fff-11n3N33n3-988
9fkr-rtt488-344-45
r5999999Rrp-4-yei388dfi3-3444-fjj577-23
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
1234-567-8-922-222222-2-1111
0
From the following extract from a source input stream, i need to use c# regex to extract a match collection of each matching block of code between the ##if WORD ## and the matching ##endif WORD ##

##if textbox ##
		<tr>
			<td>Textbox description here, could be anything:</td>
			<td>##textbox##</td>
		</tr>
##endif textbox ##
		<tr>
			<td>multilinetextbox</td>
			<td>##multilinetextbox##</td>
		</tr>
##if staticdropdown ##
		<tr>
			<td>staticdropdown description here, could be anything or nothing or something else alltogether:</td>
			<td>##staticdropdown##</td>
		</tr>
##endif staticdropdown ##

Open in new window


The returned match should include the ##if and end ##endif blocks as below...

Match 1:
##if textbox ##
		<tr>
			<td>Textbox description here, could be anything:</td>
			<td>##textbox##</td>
		</tr>
##endif textbox ##

Open in new window


Match 2:
##if staticdropdown ##
		<tr>
			<td>staticdropdown description here, could be anything or nothing or something else alltogether:</td>
			<td>##staticdropdown##</td>
		</tr>
##endif staticdropdown ##

Open in new window


I have been testing various online regex testing sites to see I I can get what I need but always end up with the match being from the very first ## if WORD ## to the very last ##endif OTHERWORD ## construct

Any help gladly accepted :D
0
Regex Destination url needs to be lower case.  I found this code that will convert it to lower case in the httpd.conf file.

RewriteMap lc int:tolower
RewriteRule (.*?[A-Z]+.*) ${lc:$1} [R]

Open in new window


Here is a sample url

http://www.theherbsplace.com/Garlic_Oil_Capsules_p_400.html

Open in new window

source url

https://www.theherbsplace.com/product/garlic_oil_capsules_p_400/

Open in new window

target url

I need to know if there is a better way to do this.  Because it seems very slow on Xampp.
0
what is an .htaccess rule to have all pages direct to index.html or site root
0
linux shared server
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] 

Open in new window


this is .htaccess code (i hope it is correct)
to have www. redirect to non www

sometimes I type wwwww.example.com or ww.example.com
could I have a rule where all subdomains forward to http://example.com
0
JavaScript, Regular-expression, Replace

I am trying to use a regular expression to correct an HL7 msg.
Using 'replace' to search the inbound text message and find segments that are not correctly terminated w/carriage returns.

Example:  // this works
var msg = "MSH|...|...|\rGT1|...|...|GT1|...|...|\r";
msg = msg.replace(/\|GT1\|/g, "|\rGT1|");

Open in new window

// This leaves me with:
MSH|...|...|\r
GT1|...|...|\r
GT1|...|...|\r

Open in new window

// but, I don't always know that the 2nd instance of 'GT1' will be proceeded w/a '|' (pipe) character.
How do I search for any character in the 1st (search) argument and get it into the 2nd (replace) argument ?
var msg = "MSH|...|...|\rGT1|...|...|GT1|...|...|\r";
msg = msg.replace(/.GT1\|/g, ".\rGT1|");
// What goes here  ^ and Here ^

Open in new window

I need to avoid adding a double \r\r !

Thank you.
0
Exploring SharePoint 2016
LVL 12
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

Hello,
how I can  create a regular exp for :
c:\windows but without match the letter case.
thanks.
0
I need some coding help... I have a string, for example:

$string = "post-title/367895378/";

The numbers there... in the string they always start with 367 and then there are anywhere from 3 to 6 digits afterwards.

I need to remove the "367" and all the numbers afterwards, and the trailing slant, so that the string ends up as "post-title/" (the post title changes based on the page it's on, of course).

The numbers starting with 367... and the slant are always going to be at the end of the url, so everything starting with 367 and afterwards should be eliminated.

I know that needs some kind of regex, but that's beyond my skills...

Thanks,

Chris
0
Hey

"Super Duper (1235)"
"Doggy (1234567)"

I need to get the numbers between () (regEx)?

How to)

Thanks in advance

Mike
0
I need to remove an encoded ? (%3F) off of several url's.  I want to use Mod_Rewrite to accomplish that.  Here is my regex but it itsn't working.

RewriteRule ^index\.php\?controller=cms&id_cms=([0-9]+)%3F$ /index.php?controller=cms&id_cms=$1 [R=301,L]

Open in new window


This is what the original url looks like
/index.php?controller=cms&id_cms=73%3F

Open in new window


Please tell me how to get rid of the %3F appended to the url.
0
In an effort to streamline and systematize error message that are presented to the user from the application system we are developing/sustaining, I have made a complete list of error message and where they are found in the code base.

Except for error messages that origin from views and stored procedures in the MSSQL database that is the backend for this system.

When I searched for error messages in the application code base, I used regular expressions to look for hardcoded error messages in the source code. I also manually looked through all .resx files for error messages. But I am not sure of what is the best approach when searching for error messages in views and stored procedures.

The amount of views and stored procedures in the database backend is huge, and it will take an immense amount of time to read through it all manually. I also don't trust that I will catch all error messages sufficiently by manually reading all the code.

So, are there any good ideas on how to approach this task of finding error messages in views and stored procedures in an MSSQL database in a quick as possible and efficient way?
0
I'm trying to extract a list of parameter names from a Python script. Here's an example of what I'm looking at
def foo(cmd
    ,pIncludeAll #BOOL
    ,pOrderByDisplayOrder #BOOL
    ) :
    try:
        ....

Open in new window

Currently, I'm using a Regex that grabs everything between the parentheses then just splitting on the comma. This doesn't work in the above case since there are comments after 2 of the 3 parameters. My split string ends up looking like this:
cmd
pIncludeAll #BOOL
pOrderByDisplayOrder #BOOL

Open in new window

What I need is a Regex that will produce a match result that contains each of the parameters without the comment like this:
cmd
pIncludeAll
pOrderByDisplayOrder

Open in new window

I know I need to delimit the Regex match on commas, whitespace, and pound signs. I just don't know how to write the expression so that it will return a proper match against an arbitrary number of arguments.
0

Regular Expressions

A regular expression ("regex") is a sequence of characters that define a search pattern, mainly for use in pattern matching with strings, or string matching, i.e. "find and replace"-like operations. Regular expression processors are found in several search engines, search and replace dialogs of several word processors and text editors, and in the command lines of text processing utilities, such as sed and AWK. Many programming languages provide regular expression capabilities, some built-in, for example Perl, JavaScript, Ruby, AWK, and Tcl, and others via a standard library, for example .NET languages, Java, Python and C++ (since C++11). Most other languages offer regular expressions via a library.