regex

How to replace text not within a specific-Tag in JavaScript

I have a string (partly HTML) where I want to replace the string :-) into bbcode :wink:. But this replacement should not happen within <pre>, but in any other tag (or even not within a tag). For example, I want to replace :-)<pre>:-)</pre><blockquote>:-)</blockquote> to: :wink:<pre>:-)</pre><blockquote>:wink:</blockquote> I alrea...

Regexp match any uppercase characters except a particular string

I want to match all lines that have any uppercase characters in them but ignoring the string A_ To add to the complication I want to ignore everything after a different string, e.g. an open comment Here are examples of what should and shouldnt match Matches: fooBar foo Bar foo A_fooBar fooBar /* Comment */ Non Matches (C_ should n...

Automatically finding numbering patterns in filenames

Hi all, Intro I work in a facility where we have microscopes. These guys can be asked to generate 4D movies of a sample: they take e.g. 10 pictures at different Z position, then wait a certain amount of time (next timepoint) and take 10 slices again. They can be asked to save a file for each slice, and they use an explicit naming pat...

Regular expression listing all possibilities

Hey there! Given a regular expression, how can I list all possible matches? For example: AB[CD]1234, I want it to return a list like: ABC1234 ABD1234 I searched the web, but couldn't find anything. ...

Regex: How to Uppercase the first character of each word?

Is it possible to uppercase the first character of each word using regex? I'm going to be using this in VB.net (SSIS) ...

Regular Expression for dd/MM/yyy or dd/MM/yyyy hh:mm:ss

I'll admit I'm rubbish at regular expressions and find some of the tools out there that are supposed to make generating them easier painfully difficult to use. That's my fault granted.. anyway.. Can anyone come up with a single regular expression that will allow both dd/MM/yyyy and/or dd/MM/yyyy hh:mm:ss Yes, I've Googled for it and se...

regular expressions: OR (|) in subpattern not working

Hi there, I have two cases to match: either # ... ([0-9]+,[0-9]+)&nbsp;&euro; ... # or # ... (--) ... # Now, # ... (?:(--)|([0-9]+,[0-9]+)&nbsp;&euro;) ... # isn't working, it says Unknown modifier '(' ... I'm using preg_match_all() on PHP 5.3 Those above are NOT the full expressions, just extracts! ...

swedish characters check with javascript?

How can I rewrite this code to check for all characters including the swedish å, ä, and ö characters? alphaExp = /^[a-zA-Z]+$/; The above only checks against english letters! The swedish contains å, ä, ö coming after the Z... rest is all the same as english. Thanks ...

How to sort by line length, then reverse alphabetically

I have a large (600 odd) set of search and replace terms that I need to run as a sed script over some files. The problem is that the search terms are NOT orthogonal... but I think I can get away with it by sorting by line length (i.e. pull out the longest matches first, and then alphabetically within each length. So given an unsort set o...

Java: I have a big string of html and need to extract the href="..." text...

I have this string containing a large chunk of html and am trying to extract the link from href="..." portion of the string. The href could be in one of the following forms: <a href="..." /> <a class="..." href="..." /> I don't really have a problem with regex but for some reason when I use the following code: String innerHTM...

matching string in C#

Alright, so i need to be able to match strings in ways that give me more flexibility. so, here is an example. for instance, if i had the string "This is my random string", i would want some way to make " *random str* ", " *is __ ran* ", " *is* ", " *this is * string ", all match up with it, i think at this point a simple true or fa...

using regex in php to add a cell in a row

As usual I have trouble writing a good regex. I am trying to make a plugin for Joomla to add a button to the optional print, email and PDF buttons produced by the core on the right of article titles. If I succeed I will distribute it under the GPL. None of the examples I found seem to work and I would like to create a php-only solution....

Javascript regular expression not working in Firefox

This regular expression fails in Firefox but works in IE. function validate(x) { return /.(jpeg|jpg)$/ig.test(x); } Can anybody explain why? ...

How to override HttpStyleUriParser/GenericUriParser for HTTP-like URLs?

I'd like to override HttpStyleUriParser, since I only want to modify it slightly. Microsoft also states (See MSDN) Microsoft strongly recommends that you use a parser shipped with the .NET Framework. Building your own parser increases the complexity of your application, and will not perform as well as the shipped parsers. However, ...

Parsing email conversations with regular expressions.

I am writing a BI application that needs to extract meta data from email conversation. Namely given an email thread I wish to extract all the participants and the structure of the conversation. For example, given a conversation like this: From: me To: You CC: someone <Body> From: You To: Someone CC: Someone else <Body> I want to e...

PHP and regex to find files in directories and then run regex

hi, what's the the most efficient way to find text files in different directories and then run regex to those found files. I will run php/scripts locally. Let's say I have D:\Script\ where i want to run my script from and D:\Script\folder_01, D:\Script\folder_02, etc. where i want that script to look the files from. Those folder names a...

How to count occurence of partly-matching words with VB.NET?

I am using VB 9.0 to split a text file and then count occurrences of the term <sequence>. Supposing I want also to count occurrences of the same term in a different format, e.g. <sequence and then group them together such that I output the result to a text box, i.e. txtMyTerms.Text=<sequence>+<sequence. How to do it? My current code is...

how to replace special characters using regular expresions?

Hi, How to replace special characters using regular expressions? By special, what I mean is those symbolic characters that appear sometimes in text. For example, in text below, I want to remove the bubble which is at the start of each line. Passport Details Name as on passport Relationship Passport Number Date of Issue Expiry Date Pl...

How to match alphabetical chars without numeric chars with Python regexp ?

Using Python module re, how to get the equivalent of the "\w" (which matches alphanumeric chars) WITHOUT matching the numeric characters (those which can be matched by "[0-9]")? Notice that the basic need is to match any character (including all unicode variation) without numerical chars (which are matched by "[0-9]"). As a final note,...

Preventing duplicate matches in RegEx

The following code string expression = "(\\{[0-9]+\\})"; RegexOptions options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase); Regex tokenParser = new Regex(expression, options); MatchCollection matches = tokenParser.Matches("The {0} is a {1} and the {2} is also a {1}"); will match and ca...