regex

How to enclose text patterns within xml elements, except when it is already inside a certain xml element?

I have several thousand xml files generated from java properties files prepared for translation in the TTX format. They contain quite a few variables, that I need to protect from the translators, as they often break such things. The variables are in the form of numbers or occasionally text between a pair of curly braces eg. {0}, {this}. ...

Would you hire a developer who doesn't know how to use regular expressions?

Would you hire a developer who doesn't know how to use regular expressions? That's about it, please state your reasons for or against, and feel free to give different answers for different situations. Just try to break up your answers if you can. ...

.NET testing a string for numeric value

Consider the need for a function in C# that will test whether a string is a numeric value. The requirements: must return a boolean. function should be able to allow for whole numbers, decimals, and negatives. assume no using Microsoft.VisualBasic to call into IsNumeric(). Here's a case of reinventing the wheel, but the exercise is goo...

RegEx for Spanish alphabets in ColdFusion 8

Hi all I know that I can use [a-z] to check for any alphabets from a to z in CF 8. However, are there any regex to detect spanish alphabets like á, í, ó, é, ñ, etc.? Thanks in advance, Monte ...

.NET RegEx help

Hi All, I am very inexperienced when it comes to regular expressions. What I'm trying to do is iterate through a list of strings and try to locate strings that are of a certain pattern. The strings I am interested in will be in the form of "some text ***{some text}***" How do I write a RegEx to match up to? I was trying this: Regex expr...

PHP - detect whitespace between strings

How would I go about detecting whitespace within a string? For example, I have a name string like: "Jane Doe" Keep in mind that I don't want to trim or replace it, just detect if whitespace exists between the first and second string. ...

Regular Expressions and GWT

My questions is: Is there a good solution to use regular expression in GWT? I'm not satisfied with the use of String.split(regex) for example. GWT translates the Code to JS and then uses the regex as a JS regex. But I cannot use something like the Java Matcher or Java Pattern. But I would need these for group matching. Is there any pos...

regex with negative matching (ie, find string that _doesn't_ match regex)

I have a log file with the string "ERROR" on some lines. I want to delete every line that doesn't have ERROR so that I can see just what needs fixing. I was going to do something like the following in vim: %s/!(ERROR)// to replace non-error lines with an empty string. I do not believe that standard regexes can do this, but maybe I'm w...

JavaScript replace/regex

Given this function: function Repeater(template) { var repeater = { markup: template, replace: function(pattern, value) { this.markup = this.markup.replace(pattern, value); } }; return repeater; }; How do I make this.markup.replace() replace globally? Here's the problem. If I use i...

How to get GL, G0 from "GL=>G0" using Ruby Regular Expression

I have following string: "xxxxx GL=>G0 yyyyyy " I want to extract GL and G0 using ruby regular expression. Thanks. ...

How do I linkify text using ActionScript 3

I have a text that I want to linkify. The text could be multiline, and could contain multiple urls like the example below. example : My current actionscript code looks like this <mx:Script> <![CDATA[ import mx.controls.Alert; import mx.rpc.events.FaultEvent; import mx.rpc.events.ResultEvent; private functi...

Regex: How to get a group name

I have a .NET Regex which looks similar to: (?<Type1>AAA)|(?<Type2>BBB) I'm using the Matches method against a sample string e.g. "AAABBBAAA", and then iterating over the matches. My goal is to find the match types, using the regex match group, so for this regex it will be: Type1 Type2 Type1 I couldn't find any GetGroupName metho...

In Perl, how can I detect if a string has multiple occurrences of double digits?

I wanted to match 110110 but not 10110. That means at least twice repeating of two consecutive digits which are the same. Any regex for that? Should match: 110110, 123445446, 12344544644 Should not match: 10110, 123445 ...

When to use parser-generator, when is regex is enough?

I have not gotten into the field of formal languages in computer science yet, so maybe my question is silly. I am writing a simple NMEA parser in C++, and I have to choose: My first idea was to build a simple finite state machine manually, but then I thought that maybe I could do it with less work, even more efficiently. I used regula...

How to update all C/C++ identifier names in a project

After frequently coming across recommendation not to use leading and double underscores in C/C++ identifiers I decided to fix all our sources once and for all. What I need to do now is convert _Identifier to Identifier_. Should I use a specialized tool for this task of regular expressions will do for this job? In latter case what is the...

Regex for searching Database-Statements in VisualStudio

I am currently working on a rather large project in Visual Studio 2008 with a lot of Database-Statements. The Statements are held in strings like this: string stmt = "SELECT ID, OTHER " + "FROM TABLE " + "WHERE CONDITION"; I was wondering how to find all Statements via regex. So I am not so good at regex, but maybe s...

Regular expression to match a decimal value range

Is there an easy way to take a dynamic decimal value and create a validation regular expression that can handle this? For example, I know that /1[0-9]{1}[0-9]{1}/ should match anything from 100-199, so what would be the best way to programmatically create a similar structure given any decimal number? I was thinking that I could just lo...

Possible to create Oracle regular expression that's able to match NULL?

In Oracle, is it possible to match both a particular string format and an empty string using a single regex? Something along the lines of: SELECT 1 FROM DUAL WHERE REGEXP_LIKE('12345', '^([1-5]{5})|NULL$'); SELECT 1 FROM DUAL WHERE REGEXP_LIKE('', '^([1-5]{5})|NULL$'); SELECT 1 FROM DUAL WHERE REGEXP_LIKE(NULL, '^([1-5]{5})|...

What is a regular expression to return the substring between two characters in a longer string?

I have a string in Perl like: "Full Name (userid)" and I want to return just the userid (everything between the "()"'s). What regular expression would do this in Perl? ...

JavaScript Replace issues

I have an array of objects that have 2 properties: Key and Value. I have a block of text with placeholders that correspond to the object Keys. I want to replace the placeholders with the corresponding Value from the object with the matching key. I have the following code: function LoadReplacementData(replacementData) { var text =...