regex

XSLT 2.0, replace function: How to replace matched group with upper case?

Hello, If have a following element in my XSL file: <xsl:value-of select="replace(lower-case(@name), '_([a-z0-9])', '$1')" /> For example from 'get_polygene_lubricants' it makes 'getpolygenelubricants'. What I want to do is to replace the first letter after '_' with the uppercase variant of the letter. I googled, read documentation, ...

Regex: Do not match if pattern at the end of the string

I have the following regex, where I want to match any explicit dot followed by one or more: <b> <i> <u> </b> </i> </u> I would like this Regex to NOT match this pattern if it occurs at the end of the string. string = Regex.Replace(string, "\.((<[\/biu]+>)+)", ".$1||") Ex: This <b>should match.</b> allright. This <i><b>shouldn't m...

Need regexp to find substring between two tokens

I suspect this has already been answered somewhere, but I can't find it, so... I need to extract a string from between two tokens in a larger string, in which the second token will probably appear again meaning... (pseudo code...) myString = "A=abc;B=def_3%^123+-;C=123;" ; myB = getInnerString(myString, "B=", ";" ) ; method getInne...

How do I place an IN parameter with a LIKE with a RowSet?

I have fighting to get a IN parameter to work inside of a LIKE statement now for hours! I am using a CachedRowSet, which I understand should follow the same rules as a PreparedStatement. Here is the basic query: CachedRowSet cache; String sql = "SELECT x " + "FROM Y " + "WHERE z LIKE '?__'" cache.setComm...

Regex replace (in Python) - a more simple way?

Any time I want to replace a piece of text that is part of a larger piece of text, I always have to do something like: "(?P<start>some_pattern)(?P<replace>foo)(?P<end>end)" And then concatenate the start group with the new data for replace and then the end group. Is there a better method for this? ...

regex: Matching parts of a string when the string contains part of a regex pattern

I want to reduce the number of patterns I have to write by using a regex that picks up any or all of the pattern when it appears in a string. Is this possible with Regex? E.g. Pattern is: "the cat sat on the mat" I would like pattern to match on following strings: "the" "the cat" "the cat sat" ... "the cat sat on the mat" But it sho...

How do I extract all {} tokens from a string using .Net's RegEx?

I need to extract tokens that are marked with curly brackets from a given string. I have tried using Expresso to construct something that will parse... ------------------------------------------------------------- "{Token1}asdasasd{Token2}asd asdacscadase dfb db {Token3}" ------------------------------------------------------------- ...

Reversing a regular expression in python

I want to reverse a regular expression. i.e. given a regular expression, I want to produce any string that will match that regex. I know how to do this from a theoretical computer science background using finite state machine, I just want to know if someone has already written a library to do this. :) I'm using Python, so I'd like a py...

Regex: Why no group for every found item?

I have the following text: <i><b>It is noticeably faster.</b></i> <i><b>They take less disk space.</i> And the following regex: (</[b|i|u]>)+(\s*)(<[b|i|u]>)+ The matching creates the following groups: 0: </b></i> <b><i> 1: </i> 2: spaces 3: <b> How can I change my regex so it creates groups like that: 0: </b></i> <b><i> 1:...

Regex to strip lat/long from a string

Anyone have a regex to strip lat/long from a string? such as: ID: 39.825 -86.88333 ...

Is it possible to match a pattern using a regular expression across a newline in UltraEdit?

The UltraEdit text editor includes a Perl and Unix compatible regex engine for searching. I want to be able to match a string line this: <branch id="attribute"> <leaf id="attribute"/> <leaf id="attribute"/> <leaf id="attribute"/> </branch> With something like this: /<branch id="attribute">.*</branch>/gis Does any one know of...

How do you pass a variable to a Regular Expression JavaScript?

I'd like to create a String.replaceAll() method in JavaScript and I'm thinking that using a RegEx would be most terse way to do it. However, I can't figure out how to pass a variable in to a RegEx. I can do this already which will replace all the instances of "B" with "A". "ABABAB".replace(/B/g, "A"); But I want to do something like...

Best way to test for existing string against a large list of comparables

Suppose you have a list of acronym's that define a value (ex. AB1,DE2,CC3) and you need to check a string value (ex. "Happy:DE2|234") to see if an acronym is found in the string. For a short list of acronym's I would usually create a simple RegEx that used a separator (ex. (AB1|DE2|CC3) ) and just look for a match. But how would I ta...

Regular expression to extract URL from an HTML link

Im newbie in Python, i learning regex, but need help here Heres comes the source <a href="http://www.ptop.se" target="_blank">http://www.ptop.se&lt;/a&gt; I trying to code a tool that only prints out http://ptop.se, Can you help me please? ...

replacing regex in java string

I have this java string: String bla = "<my:string>invalid_content</my:string>"; How can I replace the "invalid_content" piece? I know I should use something like this: bla.replaceAll(regex,"new_content"); in order to have: "<my:string>new_content</my:string>"; but I can't discover how to create the correct regex help please :)...

How to split using a prefix character using regular expressions?

I would like to split the example string -- ~Peter~Lois~Chris~Meg~Stewie on the character '~' and have the result be Peter Lois Chris Meg Stewie Using a standard string split function in javascript or C# the first result is of course an empty string. I'd like to avoid having to ignore the first result because the first result may act...

Regular Expression Compiler

I have had the need to use regular expressions only a few times in the work that I have done; however, in those few times I discovered a very powerful form of expression that would enable me to do some extremely useful things. The problem is that the language used for regular expressions is wrong - full stop. It is wrong from a psychol...

Case insensitive Python regular expression without re.compile

In Python, I can compile a regular expression to be case-insensitive using re.compile: >>> s = 'TeSt' >>> casesensitive = re.compile('test') >>> ignorecase = re.compile('test', re.IGNORECASE) >>> >>> print casesensitive.match(s) None >>> print ignorecase.match(s) <_sre.SRE_Match object at 0x02F0B608> Is there a way to do the same, bu...

replacing regex in java string, which contains `&#xA;` symbol

I have to replace the content of this xml string through java <My:tag>value_1 22&#xA;value_2 54&#xA;value_3 11</My:tag> so, this string has been taken from an xml and when I acquire it I have this result: <My:tag>value_1 22 value_2 54 value_3 11</My:tag> If I try to replace the content by this way: String regex = "(<My:tag>)(.*)(...

Regex: How to get all contents inside a tag #[SOME TEXT HERE]

I am working on a simple token replacement feature of our product. I have almost resolved all the issue but I missed one thing. A token must support attributes, and an attribute can also be a token. This is part of a bigger project. hope you can help. The begining tag is "**#[**" and the ending tag is "**]**". Say, #[FirstName], #[LastN...