@urls= $field =~ /<a.*?href="(.*?)".*?>.*?<\/a>/mgo; #multi-line, global, compile-once
@text= $field =~ /<a.*?href=".*?".*?>(.*?)<\/a>/mgo;
for ($count=0; $count<(scalar @urls); $count++){
print "\"".$text[$count]."\" goes to ->\"".$url[$count]."\"\n";}
What is the correct syntax to make this the same as the previous lines?
(@arra...
Hi,
I need to extract the email address out of this mailbox string.
I thought of str_replace but the display name and the email address is not static so I don’t know how to do this using regular expressions.
Example: "My name <[email protected]>" should result in "[email protected]".
Any ideas?
Thanks
Matthy
...
All,
Sorry - there's enough regex questions on stackoverflow already, but I can't figure this one out.
I'm working on a PHP script that reads the content of emails, and pulls out certain information to store in a database.
Using imap_fetchbody ($imap_stream, $msg_number, 1), I'm able to get at the body of the email. In some cases (esp...
I have a table called "scholarships" that has a field named "majors" which contains comma separated major names for the majors the scholarship is related too.
Let's say the field could contain one (or more separated by commas) of the following: business, agribusiness, business administration, international business.
If someone is searc...
My source string is this:
{categories group_id="3"}
{category_name}
{/categories}
{categories group_id="4"}
{category_name}
{/categories}
My regex is this:
preg_match('/{categories group_id="3"}(.*){\/categories}/s', $tagdata, $matches);
Which results in:
Array
(
[0] => Array
(
[0] => {categories group_id=...
In Javascript, is there a way (that survives internationalization) to determine whether a character is a letter or digit? That will correctly identify Ä, ç as letters, and non-English digits (which I am not going to look up as examples)!
In Java, the Character class has some static methods .isLetter(), .isDigit(), .isLetterOrDigit(), f...
Hello,
#include <iostream>
#include <algorithm>
#include<boost/algorithm/string.hpp>
#include<boost/regex.hpp>
using namespace std;
using namespace boost;
string _getBasehtttp(string url)
{
regex exrp( "^(?:http://)?([^\\/]+)(.*)$" );
match_results<string::const_iterator> what;
if( regex_search( url, ...
Even after years of programming, I'm ashamed to say that I've never really fully grasped regular expressions. In general, when a problem calls for a regex, I can usually (after a bunch of referring to syntax) come up with an appropriate one, but it's a technique that I find myself using increasingly often.
So, to teach myself and under...
Hi
I've tried dozens of different ways of doing this but can't get any of them to work. My .htaccess does a few things, like setting a custom 404 and blocking image hotlinking. I want to do two things on the URL: add www. if it isn't there (rather annoying Facebook login can't cope with two different sources!), and replacing // with / e...
For some reason I can't seem to match a parentheses in Flex using Regex to save my life.
What's wrong with this?
var commandTxt:String = "switchview(adf)";
var switchViewArray:Array = commandTxt.match(new RegExp("switchview\(", "i"));
I've tried dozens of things, but I can't seem to get a match the parentheses. What's the catch here...
I have
text text text [text text] \n
text text text [text text] \n
I want
text text text \n
text text text \n
What RE can I use?
...
I'm learning to use Java's Pattern and Matcher, and this is an example code snippet in my book. It works as the author describes, but what I don't get is why \\. ends up being a dot instead of a backslash (the \\ part) and a dot (the . part). Does the compiler not read from left to right?
import java.util.regex.*;
public class SplitTest...
I want to replace all the occurrences of a string that doesn't start with "<pre>" and doesn't end in "</pre>".
So let's say I wanted to find new-line characters and replace them with "<p/>". I can get the "not followed by" part:
var revisedHtml = html.replace(/[\n](?![<][/]pre[>])/g, "<p/>");
But I don't know the "not starting with" ...
I have a huge CSV list that needs to be broken up into smaller pieces (say, groups of 100 values each). How do I match 100 lines? The following does not work:
(^.*$){100}
...
I am matching a pattern and getting the line of the match using $.
I need to print the line matching before the particular pattern and after the particular pattern, e.g.:
line1
line2
line3
line4
line5
After my pattern matches line3, I want to print line2 and line4.
How can I do a pattern match in Perl? Can any one help me?
Thanks i...
Hi,
I'm using c# RegEx to search quoted strings in a script text.
I use this expression : new Regex("\"((?:\\\\.|[^\\\\\"]*)*)\""),
e.g "((?:\\.|[^\\\"]*)*)"
meanings to not take care of \" cases
This makes RegEx.Matches runs and never stops for some input strings.
Never mind this problem with .Net RegEx, I know my expression is not t...
What's the best way to get an array of all the URLs in a web page? and how would I do it?
...
Hi guys,
I've spent some time, but still have to solution. I need regular expression that is able to match a words with signs in it (like c++) in string.
I've used /\bword\b/, for "usual" words, it works OK. But as soon as I try /\bC\+\+\b/ it just does not work. It some how works wrong with a plus signs in it.
I need a regex to detec...
Hello,
I have a form which among others contains text inputs that contain arithmetic data (prices)
The elements and their names are dynamically generated. I would like to only "find" fields that contain arithmetic values based on their names (i.e. an example element name would be price_500_365 (from price_PRODUCTID_ORDERID). So I want ...
Hi,
I've got a string like this: 02-09-10, 20:19 (1 dagen geleden). I need the 1 inside the brackets. I used this regex:
myStr.replace(/(.+*)\(([0-9]{1,}) dagen geleden\)/i, '$2')
But that doesn't work... What to do?
Regards, dodo
...