regex

How to show which sub-regex failed to match?

Hello, I am using regular expressions to validate user input. The following code collects a matches accessible with theMatch.Groups["identifier"]. How can i get a list of sub-strings that did not match in each group? #region Using directives using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExp...

JavaScript Regex, match P but not PARAM

Using JavaScript RegEx. How can I match a <p> element(including attributes), but not <param> or other HTML elements starting with a "P". ...

RegEx string "preg_replace"

I need to do a "find and replace" on about 45k lines of a CSV file and then put this into a database. I figured I should be able to do this with PHP and preg_replace but can't seem to figure out the expression... The lines consist of one field and are all in the following format: "./1/024/9780310320241/SPSTANDARD.9780310320241.jpg" or...

Extract a certain div in HTML using Java+RegEx

I want to parse an HTML document and extract a certain div block that can be repeated. I've managed to extract THE FIRST occurrence of the block, but I cant figure out how to get the next. This is my code so far: String inputStr = HTTPGetter.get("http://someurl"); String patternStr ="<div class=\"MY-CLASS\">(.*?)</div>";...

Problem with regex again

Hello, Let say that i have this to url's site.com/hello-world/test.html site.com/hello-world/test/test.html if i go to the first url i have this regex ^.*/([a-z0-9,-]+)/([a-z0-9,-]+).html$ but url 2 is also vaild url with the regex? how to tell the regex that the first url is the url who should be vaild and not the second? ...

How can I match a word that isn't certain words?

Using a Perl or unix regex, how would I capture a word that is not a range of values. Here is what I am trying to achieve. (\w:not('int','long')) ...

.NET RegEx Performance vs. C++

Is there any published benchmark results about RegEx performance in .NET vs. unmanaged C++/C? ...

Regex problem - missing matches

Hello, Here's a short regex example: preg_match_all('~(\s+|/)(\d{2})?\s*–\s*(\d{2})?$~u', 'i love regex 00– / 03–08', $matches); print_r($matches); The regex only matches '03–08', but my intention was matching '00–' as well. What is the problem? Anyone could explain? ...

RegEx to exclude a specific string constant

Can regular expression be utilized to match any string except a specific string constant let us say "ABC" ? Is this possible to exclude just one specific string constant? Thanks your help in advance. ...

How to check if a string contains http:// at the start

I want to be able to check a string to see if it has http:// at the start and if not to add it. if (regex expression){ string = "http://"+string; } Does anyone know the regex expression to use? ...

Regex for Comma delimited list

whats the regex to validate a comma delimited list like this one 12365, 45236, 458, 1, 99996332, ...... thanks ...

Using regular expressions in CSS to hide text, is it possible?

Is it possible to use regular exprssions in css to selectively hide text? I have some text Product Pack: pack of 50 +£20.00 that I would like to display as with the monetry amount removed Product Pack: pack of 50 Can I add to CSS a regular expression that twould do that? ...

SynEdit & RegEx search

Hi, I'm looking for some example how to do regex search on SynEdit control in Delphi ? I'd like to implement something like "grep" search in the current document ... ...

javascript regex: replace url text link with image,but not in html tags

Hi this is my pice of code: <div style="overflow: hidden; width: 445px;">[IMG]http://i29.tinypic.com/mydog.png[/IMG] tak si to http://i29.tinypic.com/mycat.png Lorem ipsum loremai <img width="15" border="0" align="middle" src="images/smejo.gif" valign="middle"/> <img src=http://www.example.com/index.png alt> <img sr...

Is there a regular expression for finding/replacing the common start of all lines in a chunk of text?

Imagine this string: if(editorPart instanceof ITextEditor){ ITextEditor editor = (ITextEditor)editorPart; selection = (ITextSelection) editor.getSelectionProvider().getSelection(); }else if( editorPart instanceof MultiPageEditorPart){ //this would be the case for the XML editor selection = (ITextSelection) editorPart.getEditor...

PHP Regex Quantify

Hello, This regex only allows alphanumeric characters and one period. I haven't be able to figure out how to set a quantifier to limit the number of characters to say between five and twenty. I'm using it in PHP. /^([a-zA-Z0-9\.](?!\.)|[a-zA-Z0-9]*\.(?!\.))[a-zA-Z0-9]*$/ ...

Consecutive wild characters in email

I was looking at email validation. I read in RFC specs that consecutive . (dot) are not allowed, like, [email protected]. But are different wild characters allowed to occur consecutively? Like, [email protected]. And if so, how do I make a regular expression which will take only single occurance of wild characters as long as they a...

Using a Three Digit ASCII Code in a Regex

Is it possible to use a three digit ASCII code in a PCRE regex? A space character is a two digit one (40). You need to add a zero and escape it like so: \040 ...

Regular expressions and multiple writing systems

Types of writing systems: Alphabet Abjad Abugida Syllabary Logography In regular expressions we need to tell which "chars" we want to validate: We use something like this a-zA-Z0-9 to say that we accept all the alphanumeric. How can we make regular expressions that validate other writing systems non-alphanumerics? (how can I mak...

How can I detect Russian spam posts with Perl?

I have an English language forum site written in perl that is continually bombarded with spam in Russian. Is there a way using Perl and regex to detect Russian text so I can block it? ...