I am working on a AJAX/PHP chatroom and am currently stuck on the regex to detect if a user has send a PM & then work out who it is too and what the message is.
If the user types something like
/pm PezCuckow Hi There you so awesome!
I would like to first test if my string matched that pattern then get 'PezCuckow' and 'Hi There you...
This might sound like a stupid question, but I had a long talk with some of my fellow developers and it sounded like a fun thing to think of.
So; what's your thought - what does a Regex look like, that will never be matched by any string, ever!
Edit: Why I want this? Well, firstly because I find it interesting to think of such an expre...
I I have a timezone taken from a user that must be converted into total minutes to be stored in the database. I have the following code and it looks pretty ugly. I am new to C# and was wondering if there is a better way to do this.
string tz = userList.Rows[0][1].ToString().Trim();
//Timezones can take the form of + or - followe...
I have text in the form:
Name=Value1
Name=Value2
Name=Value3
Using Perl, I would like to match /Name=(.+?)/ every time it appears and extract the (.+?) and push it onto an array. I know I can use $1 to get the text I need and I can use =~ to perform the regex matching, but I don't know how to get all matches.
...
I'm new to regular expressions, and I need to write a set of regular expressions that match different data packet formats.
My problem is, usually I only need to look for the start and ending parts of the packet to distinguish between them, the data in between is irrelevant.
What's the most efficient way to ignore the data between the s...
I want a reg exp for generating SEO-friendly URLs, so things like:
My product name
becomes
My_product_name
This is a long,long,long!!sentence
becomes
This_is_a_long_long_long_sentence
Basically so all non-alphanumeric chars are removed and replaced with underscores.
Any ideas?
...
I need to figure out a regular expression to delete all lines that do not begin with either "+" or "-".
I want to print a paper copy of a large diff file, but it shows 5 or so lines before and after the actual diff.
...
I am replacing all occurances of \n with the <BR> tag, but for some reason the text entered has many \n in a row, so I need to combine them.
Basically, if more than 1 \n occur together, replace it with just a single <BR> tag.
Can someone help me with this?
...
Okay, so I'm working with html and I want to match everything between two comments generated by a CMS - including linebreaks.
Example:
<!-- Start Magic -->
<h2>My title</h2>
<p>Here's some content</p>
<p>And hey look, a linebreak!
And here's another for good measure!
</p>
<!-- End Magic -->
And here's the Regex I'm using to extract t...
Here is the pattern that I want to match:
<div class="class">
<a href="http://www.example.com/something"> I want to be able to capture this text</a>
<span class="ptBrand">
This is what I am doing:
$pattern='{<div class="productTitle">[\n]<((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)>([...
I'd like to have one regular expression to find all curly brackets and replace them with other strings.
For example, I want to replace "{foo}" with "FOO" and "{bar}" with "BAR" and "{}" with "EMPTY". If the input is "abc {foo} def {bar} {}", then the output is "abc FOO def BAR EMPTY".
Nested brackets or un-coupled brackets are not allo...
I found a GreaseMonkey script on Userscripts which corrects spelling and some grammar which I'm trying to improve for use on Reddit etc. I've had some help from there improving it, and this is my current version which does work quite well.
There is, however, a problem in that it capitalises italics, bold and links. I would like to have...
Using Python I want to replace all URLs in a body of text with links to those URLs, like what Gmail does.
Can this be done in a one liner regular expression?
Edit: by body of text I just meant plain text - no HTML
...
Here is a sample HTML document that I am passing as MemoryStream in the code as given below
<h5>Sample Document </h5>
<h3> Present Tense </h3>
</p><p>The present tense is just as you have learned. You take the dictionary form of a verb, drop the 다, add the appropriate ending.
</p><p>먹다 - 먹 + 어Ꮫ...
Due to limitations i need to write ONE regex and i would like to blacklist instead of whitelist certain strings (or sites)
Here i want to disallow youtube and IP address. Below is code that matches the two site. How can i NOT match them and allow the two google (or any other site) to match?
Here is some C# code i used to test my regex....
I have a lot of files with data to convert to percentages using basic math functions:
<param id="1" name="otb" value="0.160"/>
<param id="2" name="blm" value="-0.210"/>
<param id="3" name="mep" value="-0.010"/>
<param id="4" name="plc" value="-0.100"/>
Each id get's it's own equation:
(n-(-.3))/2.3*100
(n-(-.8))/3.3*100
(n-(-.5))/1....
Using regex (in c#.net) is it possible to check the previous line of a string?
For instance, I need to select strings in which the previous line is not a series of asterisks (prev line:******)
...
Hi,
I want to match the following: a zero length line, with the match continuing across lines of non-zero length until a particular string is matched in a line. E.g: the match starts with a zero length line and continues until STOP is reached:
Some random text I don't care about
The match starts at the beginning of this line
The match...
Hi i am trying to do a find and replace on files for this
<?php include $_SERVER["DOCUMENT_ROOT"]."/articles/[^a-z]/footer.php"; ?>
to
<?php include $_SERVER["DOCUMENT_ROOT"]."/includes/class/footer.php"; ?>
but for some reason it is not working! i have a clue that its the / messing it up?
Cheers
...
I have a string like:
"This is AA and this is AA and this is AA and this is the END blah blah"
I want to match:
"AA and this is the END"
ie, ending in END, back to the first occurance of AA before END. (Language is Java)
...