regex

Regular expression to remove empty <span> tags

Hello, I would like such empty span tags (filled with &nbsp; and space) to be removed: <span> &nbsp; &nbsp; &nbsp; </span> I've tried with this regex, but it needs adjusting: (<span>(&nbsp;|\s)*</span>) preg_replace('#<span>(&nbsp;|\s)*</span>#si','<\\1>',$encoded); Cheers. ...

How to recognize a path inside a string

Just that... I get a string which contains a path to a file plus some arguments. How can I recognize the path? I thought about the index of the '.' in the file... but I don't like it. What about using regular expressions? Can anyone point me in the right direction? Regards Edit: Theses are valid entries... somefile.msi /a C:\MyFolder\S...

Regex - Using Groups and MatchCollection - Problems

Hello, I try to keep it brief and concise. I have to write a program that takes queries in SQL form and searches an XML. Right now I am trying to disassemble a string into logical pieces so I can work with them. I have a string as input and want to get a MatchCollection as output. Please not that the test string below is of a special f...

Positive lookahead for exclamation mark

I'm trying to build a Java regular expression to match ".jar!" The catch is that I don't want the matcher to consume the exclamation mark. I tried using Pattern.compile("\\.jar(?=!)") but that failed. As did escaping the exclamation mark. Can anyone get this to work or is this a JDK bug? UPDATE: I feel like an idiot, Pattern.compile("...

How can I make this regex more compact?

Let's say I have a line of text like this Small 0.0..20.0 0.00 1.49 25.71 41.05 12.31 0.00 80.56 I want to capture the last six numbers and ignore the Small and the first two groups of numbers. For this exercise, let's ignore the fact that it might be easier to just do some sort of string-split instead of a regular...

I've got problem with fine tuning of regex

i've got regex which was alright, but as it camed out doesn't work well in some situations Keep eye on message preview cause message editor do some tricky things with "\" [\[]?[\^%#\$\*@\-;].*?[\^%#\$\*@\-;][\]] its task is to find pattern which in general looks like that [ABA] A - char from set ^,%,#,$,*,@,-,; B - some te...

Regular expression to convert substring to link

Hi, i need a Regular Expression to convert a a string to a link.i wrote something but it doesnt work in asp.net.i couldnt solve and i am new in Regular Expression.This function converts (bkz: string) to (bkz: show.aspx?td=string) Dim pattern As String = "&lt;bkz[a-z0-9$-$&-&.-.ö-öı-ış-şç-çğ-ğü-ü\s]+)&gt;" Dim regex As New Regex(pattern...

What is the regular expression for the "root" of a website in django?

I'm using django and when users go to www.website.com/ I want to point them to the index view. Right now I'm doing this: (r'^$', 'ideas.idea.views.index'), However, it's not working. I'm assuming my regular expression is wrong. Can anyone help me out? I've looked at python regular expressions but they didn't help me. ...

Regex match question

In javascript, I've got a block of HTML like this: <h2>{title}</h2> <p><a href="{url}">{content}</a></p> And I'm trying use regex "match" to spit out an array of all the {item}'s. So my output should look like: ['title', 'url', 'content'] I've gotten as far as: var pattern = new RegExp("\{[a-zA-Z]+\}+"); var match = pattern.exec("...

Using Regular Expressions in JSP EL

In EL expressions, used in a jsp page, strings are taken literally. For example, in the following code snippet <c:when test="${myvar == 'prefix.*'}"> test does not evaluate to true if the value of myvar is 'prefixxxxx.' Does anyone know if there is a way to have the string interpreted as a regex instead? Does EL have something sim...

How can I extract lines of text from a file?

I have a directory full of files and I need to pull the headers and footers off of them. They are all variable length so using head or tail isn't going to work. Each file does have a line I can search for, but I don't want to include the line in the results. It's usually *** Start (more text here) And ends with *** Finish (more te...

Build a regular expression to find id in an href.

Could someone show me a regular expression that would look through this document and select the href value of every href that has RELATION_ID on the end of it? Then if it does, I have to get the Id that is before the question mark (example href="dctm://ISDOFSDdev/37004e1f800021f3?DMS_OBJECT_SPEC=RELATION_ID") Thanks! <?xml version="1.0...

Regex to select something between a #OnlinePopup and _

Can someone show me a regex to select #OnlinePopup_AFE53E2CACBF4D8196E6360D4DDB6B70 its okay to assume #OnlinePopup ~DCTM~dctm://aicpcudev/37004e1f8000219e?DMS_OBJECT_SPEC=RELATION_ID#OnlinePopup_AFE53E2CACBF4D8196E6360D4DDB6B70_11472026_1214836152225_6455280574472127786 ...

regex compare two numbers

can i somehow compare two numbers in regex? i want regex that is correct for 10-12, but incorrect for 12-10. I mean that 10 must be smaller than 12. I want to do it in Javascript. ...

RegEx matching HTML tags and extracting text

I have a string of test like this: <customtag>hey</customtag> I want to use a RegEx to modify the text between the "customtag" tags so that it might look like this: <customtag>hey, this is changed!</customtag> I know that I can use a MatchEvaluator to modify the text, but I'm unsure of the proper RegEx syntax to use. Any help would...

Regular expression library for vc6 Cstring?

Is there any regular expression library that i can use with CString of vc6? Opensource/Free library is needed ...

Regex to replace text only when occurs outside of two strings?

I would like to replace "&gt" with ">" and "&lt" with "<" but only when they occur outside "<pre>" and "</pre>". Is this possible? $newText = preg_replace('&gt', '>', $text); I would be using the preg_replace in PHP as above. ...

Javascript Hashmap key compiled into a regular expression

The monthRegex regular expression always returns true, even if dateInput is something like "December 1, 2008" by my thoughts it should match a regular expression by whichever key I pass into it. But that isn't what happens, it just returns true, and detects "JAN" as the month. function dateFormat(dateInput) { var formattedDate = ...

Best Way To Find Pattern 6 digit space 7 digit ###### ####### with VB.NET

Parsing a text file in vb.net and need to locate the latitude and longitude in these two sections of text. The patter is 6 digits space 7 digits (364800 0953600). The samples are from two different map files and have slightly differing formats. I 2H02 364800 0953600 ' SEC72 10496300- I 2H05 36...

RegEx no match in VB.NET

Hi folks I am making a mp3 id3tag editor, and a regex is not matching. Could anyone help me please? my code: arquivo = "[coletanea] album [CD #] [faixa] [artista] musica.mp3" r = New Regex("^\[(?<1>[^\]]+?)\]\s*(?<2>[\w\s]+)\s*\[CD\s*(?<3>\d+)\]\s*\[(?<4>\d+)\]\s*\[(?<5>[^\]]+)\]\s*(?<6>.+)", RegexOptions.Compiled) m = r.Match(Mid(arq...