I am looking for the best br2nl function. I would like to replace all instances of <br> and <br /> with newlines \n. Much like the nl2br function but the opposite.
I know there are several solutions in the PHP manual comments but I'm looking for feedback from the SO community on possible solutions.
...
Hi
I know that as3 has some powerful new text search capabilities, especially when combined with regex.
I don't even know if this is possible, but I would like to somehow, search any block of text, and return all nouns, adjectives and verbs.
What would be the best(most efficent) way to do this?
Is regex an option?
or would I have to lo...
I have a function to pick out lumps from a list of strings and return them as another list:
def filterPick(lines,regex):
result = []
for l in lines:
match = re.search(regex,l)
if match:
result += [match.group(1)]
return result
Is there a way to reformulate this as a list comprehension? Obviously...
In the streams I am parsing I need to parse something in this pattern:
<b>PaintTitle</b></td><td class=detail valign="top" align=left><div align=left><font size=small><b>The new great album by Pet Shop Boys</b>
How would I get the string "The new great album by Pet Shop Boys" where <b>PaintTitle</b> is guaranteed to be once per album?...
I'm exploring the power of regular expressions, so I'm just wondering if something like this is possible:
public class StringSplit {
public static void main(String args[]) {
System.out.println(
java.util.Arrays.deepToString(
"12345".split(INSERT_REGEX_HERE)
)
); // prints "[12,...
I need a way to convert a number into formatted way by inserting comma at suitable places. Can it be done using regex?
Example:
12345 => 12,345
1234567 =>1,234,567
...
I have been trying several regular expressions in the substitution operator:
$str =~ s/^0+(.)/$1/;
converts 0000 to 0 and 0001 to 1
$str =~ s/^0+./$1/;
converts 0000 to empty string, 000100 to 00, 0001100 to 100.
what difference is the parentheses making?
...
I need to check If a column value (string) in SQL server table starts with a small letter and can only contain '_', '-', numbers and alphabets. I know I can use a SQL server CLR function for that. However, I am trying to implement that validation using a scalar UDF and could make very little here...I can use 'NOT LIKE', but I am not sure...
I have a HTML string and want to replace all links to just a text.
E.g. having
Some text <a href="http://google.com/">Google</a>.
need to get
Some text Google.
What regex should I use?
...
I have form where user submits field. Field can have letters, numbers, and punctuation. But I want to check to make sure that at least 3 of the characters are letters. How can I regex that?
For example,
$string = "ab'c";
And I need something like,
if (preg_match("/[a-z]{3}/i", $string))
print "true";
else
print "false";
Th...
i just discovered http://code.google.com/p/re2, a promising library that uses a long-neglected way (Thompson NFA) to implement a regular expression engine that can be orders of magnitudes faster than the available engines of awk, Perl, or Python.
so i downloaded the code and did the usual sudo make install thing. however, that action h...
Here I am downloading a web-page source code then storing it in text file. Then I read that file and match it with a regex to search for a specific string.
There is no compiler error.
Exception in thread "main" java.lang.NoClassDefFoundError: java/lang/CharSequence
Can anybody tell me Where I am wrong.
java version "1.3.1_01"
Java(T...
Is it possible to do a case insensitive match in C# using the Regex class without setting the RegexOptions.IgnoreCase flag?
What I would like to be able to do is within the regex itself define whether or not I want the match operation to be done in a case insensitive manner.
I would like this regex, taylor, to match on the following va...
Hello:
I'm tyring to remove lowercase sentence fragments from standard text files using regular expresions or a simple Perl oneliner.
These are commonly referred to as speech or attribution tags, for example - he said, she said, etc.
This example shows before and after using manual deletion:
Original:
"Ah, that's perfectly tr...
I know a little bit of regex, but not mutch. What is the best way to get just the number out of the following html. (I want to have 32 returned). the values of width,row span, and size are all different in this horrible html page. Any help?
<td width=14 rowspan=2 align=right><font size=2 face="helvetica">32</font></td>
...
hi, can any body help me on separating this example of data that i need to parse and seperate text just like PHPDoc. It is PHP source code.
The example string :
function one_to_tree() {
//bla bla bla
return FALSE;
}
function two_to_tree() {
//bla bla bla
return FALSE;
}
function three_to_tree() {
...
Content:
1. Text is here.
20. More text.
Why does this Vim search and replace string fail?
:%s/^\d+\.\s+/# /g
...
Hi,
I have a set of expressions representing some formula with some parameters inside. Like:
[parameter1] * [parameter2] * [multiplier]
And many others like this.
I want to use a regular expression so that I can get a list of strings (List<string>) which will have the following inside:
[paramter1]
[paramter2]
[multiplier]
I am n...
I'm trying to make an url that adds a / to all hrefs and srcs in a string.
It should only add a / to urls that don't have a http:// at their beginning and that don't have / yet also.
If we have this:
<a href="ABC">...
<img src="DEFG">...
<a href="/HIJ">...
<a href="http://KLMN">...
The results should be something like this:
<a hr...
Is there a way to obtain the C++ equivalent of Perl's PREMATCH ($`) and POSTMATCH ($') from pcrecpp? I would be happy with a string, a char *, or pairs indices/startpos+length that point at this.
StringPiece seems like it might accomplish part of this, but I'm not certain how to get it.
in perl:
$_ = "Hello world";
if (/lo\s/) {
$...