regex

ASP.net PasswordStrengthRegularExpression to prevent common passwords like "11111" or "123456"

A customer asked me to prevent users from typing common passwords, but permit them to use only alphanumeric passwords. Do you know a regular expression to use in the built in PasswordStrengthRegularExpression option? Edit: I know is pretty vague, and that what I told the client. The definition is something like Do not allow the same ...

Validate URL in java

Hi, Does anyone know how to validate the format of a url in Java using regex? Thanks ...

Creating Slugs from Titles?

I have everything in place to create slugs from titles, but there is one issue. My RegEx replaces spaces with hyphens. But when a user types "Hi     there" (multiple spaces) the slug ends up as "Hi-----there". When really it should be "Hi-there". Should I create the regular expression so that it only replaces a space when there is a cha...

What is a good way to match a part of a line using command line tools?

I want to match a part of a line for example in the sentence: "The super id=42 or something." I want to return the number 42. echo "The super id=42 or something" | grep -o 'id=[0-9]+' | sed 's/id=//' Would return the correct answer, but is there a more elegant way of solving this, for example by using only one tool? ...

How can I check if a html document includes script tags that are not empty using a regular expression

I am trying to check if a html document includes script tags that are not empty using regular expressions. The regular expression should match any script tag with a content other than whitespaces or linebreaks. I have tried <script\b[^>]*>[^.+$]</script> but this regex only finds script tags with one space. ...

Regex for retrieving the parameter of the css url function...

Hi, I'm trying to get the url portion of the following string: url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) So the required part if images/ui-bg_highlight-soft_75_cccccc_1x100.png. Currently I've got this: url\((?<url>.*)\) But it seems to be choking on the following example: url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50...

How to rip specific data from an HTML file?

Hi, so I have multiple HTML files which I need to get some praticular data from, I mean theres a bunch of non relative information in this HTML files, but I need just lets say things that are between the <div class="myInfo"> and </div>, after getting this information I want to handle it in my own PHP page, so for example I can insert thi...

Determine if string ends in whitespace

Given a string that ends in a whitespace character return true. I'm sure I should be able to do this with regular expressions but I'm not having any luck. MSDN reference for regular expressions tells me that \s should match on a whitespace, but I can't figure the rest out. ...

Regex: Strip HTML attributes except SRC

Hi, I'm trying to write a regular expression that will strip all tag attributes except for the SRC attribute. For example: <p id="paragraph" class="green">This is a paragraph with an image <img src="/path/to/image.jpg" width="50" height="75"/></p> Would be returned as: <p>This is a paragraph with an image <img src="/path/to/image.jp...

Replacing Credit Card Numbers

Hi, I'm using an sql to replace credit card numbers with xxxx and finding that REGEX_REPLACE does not consistently replace everything. Below is the SET command i'm using on the SQL SET COMMENTS_LONG = REGEXP_REPLACE (COMMENTS_LONG,'\D[1-6]\d{3}.\d{4}.\d{4}.\d{3}(\d{1}.\d{3})?|\D[1-6]\d{12,15}|\D[1-6]\d{3}.\d{3}.?\d{3}...

I need a regex to return true for 01.mp4

I want to sort out specific files depending on their names, i want a regex that returns true for file names like : 01.mp4, 99.avi, 05.mpg. the file extensions must match exactly to the ones that i want and the filename must start with characters which can not be longer than 2 characters. the first part is done but the file extensions ar...

Need to split a string into two parts in java

I have a string which contains a contiguous chunk of digits and then a contiguous chunk of characters. I need to split them into two parts (one integer part, and one string). I tried using String.split("\D", 1), but it is eating up first character. I checked all the String API and didn't find a suitable method. Is there any method for ...

regex for PropertyName e.g. HelloWorld2HowAreYou would get Hello HelloWorld2 HelloWorld2How ...

I need a regex for PropertyName e.g. HelloWorld2HowAreYou would get: Hello HelloWorld2 HelloWorld2How etc. I want to use it in C# ...

Matching content between tags in web source

Hello, I was wondering what could be the fastest and the easiest way to grab text that is between tags in string. For example i have this string: Lorem ipsum <a>dolor sit amet</a>, <b>consectetur</b> adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. And i need to find text that is between tags <a> </a> ...

XSLT: Regular Expression function does not work?

Ok, this one has been driving me up the wall... I have a xslt function that is supposed to split out the Zip-code part from a Zip+City string depending on the country. I cannot get it to work! This is what I got so far: <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/functi...

Matching a+ in a regex

This should be easy, but I've managed to stump 2 people so far at work & I've been at it for over 3 hours now, so here goes. I need to replace a+ with aplus (along with a few other cases) with the Python re module. eg. "I passed my a+ exam." needs to become "I passed my aplus exam." Just using \ba+ works fine most of the time, but fai...

Regular expression for removing white spaces but not those inside ""

I have the following input string: key1 = "test string1" ; key2 = "test string 2" I need to convert it to the following without tokenizing key1="test string1";key2="test string 2" ...

Custom RegEx expression for validating different possibilities of phone number entries?

Hi, I'm looking for a custom RegEx expression (that works!) to will validate common phone number with area code entries (no country code) such as: 111-111-1111 (111) 111-1111 (111)111-1111 111 111 1111 111.111.1111 1111111111 And combinations of these / anything else I may have forgotton. Also, is it possible to have the RegEx ex...

Very Simple Regex Question

I have a very simple regex question. Suppose I have 2 conditions: url =http://www.abc.com/cde/def url =https://www.abc.com/sadfl/dsaf How can I extract the baseUrl using regex? Sample output: http://www.abc.com https://www.abc.com ...

Getting youtube links from embedded youtube video on pages?

Is there a regex to get youtube video links or ids from embedded youtube videos on webpages? ...