regex

C# RegEx: Ignore case... in pattern?

I'm using System.Text.RegularExpressions.Regex.IsMatch(testString, regexPattern) to do some searches in strings. Is there a way to specify in the regexPattern string that the pattern should ignore case? (I.e. without using Regex.IsMatch(testString, regexPattern, RegexOptions.IgnoreCase)) ...

Grep multi-layered iterable for strings that match (Python)

Say that we have a multilayered iterable with some strings at the "final" level, yes strings are iterable, but I think that you get my meaning: ['something', ('Diff', ('diff', 'udiff'), ('*.diff', '*.patch'), ('text/x-diff', 'text/x-patch')), ('Delphi', ('delphi', 'pas', 'pascal', 'objectpascal'), ('*.pas',), ('text/x-pascal',['lets',...

preg_match not splitting one result

Hi this code SHOULD put all segments into an array. $dir = "../www.cms.actwebdesigns.co.uk2/logged.php"; #$dir = "../../logged.php"; $str = base64_encode(htmlspecialchars(preg_replace("#(?:\s\s+)|(?:\n)|(?:\t)|(?:\r)#", " ", file_get_contents($dir)))); $dataToAdd = array(); for($x=0; true; $x++) { if(preg_match("#(".base64_en...

ASP.NET, JQuery - Sharing regular expressions

If you have a fair number of regular expressions used by both client (javascript) and server side code (C#, vb.net) and want to store them in one place to avoid duplication, where do you store them? I could use registerscript and write out the regex as strings, but just wondering if there is something more elegant. ...

Is Regular Expressions the best way to go about matching and replacing text?

I am well aware of what regular expressions are, so please avoid giving me definitions. I am merely looking for an opinion, and maybe even some advice. I am graduating soon with my degree in computer science, and to this point, The only education I have gotten on regular expressions, is through a course on PL design and development. We ...

Help with regular expressions (php)

Hello there! Could you please point me to the mistake in my regular expression? /[\x{4e00}-\x{9fa5}]*[.\s]*\[\/m\][\x{4e00}-\x{9fa5}]/u My string starts with chinese character ([\x{4e00}-\x{9fa5}]), which is followed by any character and ends with '[/m]' and another chinese character. So the string possibly could look like: 我... some...

PHP and Regex - storing a piece of the string for later use in replacement?

Not sure if the subject was clear, hard to describe, easy to show: I need to convert this: $text = 'Bunch of text %img_Green %img_Red and some more text here'; to this: $text = 'Bunch of text <img src="/assets/images/Green.gif" alt="Green" /> <img src="/assets/images/Red.gif" alt="Red" /> and some more text here'; Thanks in advan...

some help with this php regular expression

I have this HTML that I am reading from wordpress into a regular PHP file. This is not valid HTML but wordpress is supposed to strip the [caption] out take the img tag, and put it into a div with the caption as a <p> tag. But I want to do this in PHP, with no wordpress. [caption id="" align="alignnone" width="190" caption="my caption"]h...

regular expression ^[A-Za-z ]+$

^[A-Za-z ]+$ this expression working but it is not accepting single space i want to accept one space like 'data base'. ^[A-Za-z ]+$ this expression not taking space it taking like 'database' i want 'data base' like this help me. thank u ...

Regex - extract info from a String in Java

Hi all, I have a problem in applying a regex in my Java code. My text string is like this (String myString) name: Abc Def; blah: 1 2 3; second name: Ghi; I need to extract the name information (Abc Def). Name can contain a string of 1+ words. All the properties (name, blah, second name) are spaced with some w...

Replacing span contents when a class name is matched in .net 2.0 (c#)

Hello I want to parse some HTML server-side, and if a DIV has a particular class, we replace the contents of that div with some new information. For example if we have: <div class="was"><span class="replacevalA"><strong>£99.99</strong></span></div> We might want to replace the £99.99 to be <em>£79.99</em> leaving us with: <div clas...

how to do the following in ruby ?

I need to grab a string like "/html/body/a" i need to check the last portion, in this case "a" after the final "/" how can i do this ? how can i regex match for the last item after the final "/" ? ...

how to remove all [d+] except the last [d+] ?

i have a string like /root/children[2]/header[1]/something/some[4]/table/tr[1]/links/a/b and /root/children[2]/header[1]/something/some[4]/table/tr[2] how can i reproduce the string so that all the /\[\d+\]/ are removed except for the last /\[\d+\]/ ? so i should end up with . /root/children/header/something/some/table/tr[1]/lin...

how do I replace nonrepeating character through .Net regular expression

I have a string. I want to replace "d" with "dd", using Regex.Replace, but only if the d is not repeating. For example, if the string is "m/d/yy", i want to change it to "m/dd/yy". However, if the string is "m/dd/yy", i want to keep it the same, and NOT change it to "m/dddd/yy". How do I do this? I tried Reg.Replace(datePattern, "\bd\b...

How to match these strings with Regex?

<div> <a href="http://website/forum/f80/ThreadLink-new/" id="thread_gotonew_565407"><img class="inlineimg" src="http://website/forum/images/buttons/firstnew.gif" alt="Go to first new post" border="0" /></a> [MULTI] <a href="http://website/forum/f80/ThreadLink/" id="thread_title_565407" style="font-weight:bold">THR...

How can I speed up my Perl regex matching?

I want to capture several text using the following regex: $text_normal = qr{^(\/F\d+) FF (.*?) SCF SF (.*?) MV (\(.*?)SH$}; A sample of the string is like below: my $text = '/F12345 FF FF this is SCF SF really MV (important stuff SH'; Can that be rewritten to speed up the matching? ...

Regex match question

If I have a string such as lotsofcrap"somethingimportant"moreotherstuff is it possible to get Regex to match just whatever is between the " ", excluding the quotation marks? So the way to detect it would be something like ".*", but that will return "somethingimportant" rather than just pure somethingimportant ...

Regular expression validation (should start with character )

In my web application, I have a text box. The user should enter a value of which the first character is a letter, not a digit, and the remaining characters can be alphanumeric. How can I write regular expression to do this? ...

Simple Regex match question?

I have a stringstream where it has many strings inside like this: <A style="FONT-WEIGHT: bold" id=thread_title_559960 href="http://microsoft.com/forum/f80/topicName-1234/"&gt;Beautiful Topic Name</A> </DIV> I am trying to get appropriate links that starts with: style="FONT-WEIGHT: bold So in the end I will have the link: h...

mod_rewrite: periods from URI gone in the query string

Problem: See examples below. When using mod_rewrite to put "the URI part after the script name" into the query string (in any way), the ending periods (.) of every "directory" are removed. (Apache 2.2.14 on win32.) Question: Is there any way to solve this or do I have to parse REQUEST_URI? Request ("."s escaped): http://localhost/simp...