Possible Duplicate:
How to determine if a number is a prime with regex?
This page claims that this regular expression discovers non-prime numbers (and by counter-example: primes):
/^1?$|^(11+?)\1+$/
How does this find primes?
...
I'm trying to match tags using preg_replace. The regex used is: <video[^>]*>(.*?)</video>
But I'm getting a server warning: Message: preg_replace() [function.preg-replace]: Unknown modifier ']'
Any clues on why?
Also, How could I modify the regex so it can match [video] tags instead?
Thanks!
...
The below regex's don't seem to be working. Is it because of !preg_match?
Username
if (!preg_match("/^[A-Za-z](?=[A-Za-z0-9_.]{3,31}$)[a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*$/",$_POST['username'])) {
$hasErr = true;
$return['username'] = 'Please enter a valid username. Use 4 to 32 characters '
. 'and start with a l...
I'm wanting to (in Java) find any substrings in a string which start with say aba and end in say aca, where there is one or more non-whitespace chars between them.
For example" blingblangabablahacablingblang would find the substring abablahaca.
Then I want to replace each of those substrings, modifying the start to just b and the end t...
Hi all,
I am trying to validate a twitter url, so that at least it contains a username. I do not care if it exists or not, just that there is one.
I am using the below javascript regex
var re = new RegExp('((http://)|(www\.))twitter\.com/(\w+)');
alert(re.test('http://twitter.com/test_user'));
but it is not working.
The strange thi...
I got some html text, which contains all kinds of html tags, such as <table>, <a>, <img>, and so on.
Now I want to use a regular expression to remove all the html tags, except <img ...> and </img>(and upper case <IMG></IMG>).
How to do this?
UPDATE:
My task is very simple, it just print the text content(including images) of a html...
hi, i have this pattern i using to replace string:
var html = "some test string";
var regex = new Regex(@"<(.|\n)+?>", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline);
var result = regex.Replace(html, ?);
this pattern matches all html tags <anything here> and replace with ?. actually ? is " " or "" accordin...
I am writing an application to get the title of an html page, some text under the body tag and an image.
It is something like the share stuff of facebook. I can get a regular expression that does that. Thanks for your assitance.
...
hello, I'm trying to parse block from html page so i try to preg_match this block with php
if( preg_match('<\/div>(.*?)<div class="adsdiv">', $data, $t))
but doesn't work
</div>
blablabla
blablabla
blablabla
<div class="adsdiv">
i want grep only blablabla blablabla words
any help
...
Let's say users browse to
http://www.site.com/test1/test2/test3
now I would like to rewrite the url to
http://www.site.com/index.cfm?var1=test1&var2=test2&var3=test3
So far I have added the following in the resin.conf file:
<web-app id="/" root-directory="webroot">
<rewrite-dispatch>
<forward regexp="^/([^/]+...
Suppose we have one sentence (several words without a dot after the last one).
I need to wrap the last word with some html tags (for example, <strong>lastword</strong>).
How can I achieve this with java regular expressions?
I've already tried this:
"John Doe Jr".replaceAll ("( .+$)", "<strong>$1</strong>");
but it results in
John...
1) ^[^\s].{1,20}$
2) ^[-/@#&$*\w\s]+$
3) ^([\w]{3})$
Are there any links for more information?
...
I would like to know if the result of RegEx.IsMatch is affected by encoding.
I am checking if a string is contained within another one by using a regular expression pattern.
I am 99.9 % sure the pattern is correct, so my question is...
The matching test with the Regex.IsMatch, is applied on "byte level" or "string level"?
UPDATE:
...
I have written following regular expression /^[A-Za-z0-9-_\s]*$/ in PHP which allows numbers, letters, spaces, hyphen and underscore. I want to display those matches which are not valid against the regex i.e "My Name is Blahblah!!!" should give me "!!!" output.
...
I read an article the other day that briefly touched base on some common validation flaws in most modern websites, and I decided to do some research on it.
Turns out, MOST websites, and email providers (hotmail, yahoo) are being TOO STRICT with their validation.
-
In section 2.3.10 of RFC 2821
Consequently, and due to a long hist...
How do I write a regular expression that will match all words starting with I except the word Integer?
Example:
t1: Integer;
t2: Interface;
t3: IXml;
The result should be Interface and IXml.
...
I'm trying to write a validator for an ASP.NET txtbox.
How can I validate so the regular expression will only match if the 6th character is a "C" or a "P"?
...
Unfortunately my hMailServer can't send emails to Hotmail. How can I determine whether a given email address is Hotmail or not, to prevent the message from being lost.
Hotmail e-mails can be:
* @live.com
* @live.fr[pt][ru][etc]
* @hotmail.com,
* @live.com.jp
* @msn.com
* and many country TLD specific combinations involving MSN, Hotma...
Hi all,
I would like some help with a regular expression.
I have some files like this:
JWE-766.1.pdf
JWE-766.2.pdf
JWE-768.1.pdf
JWE-770.1.pdf
I would like a regex pattern to extract the number after 'JWE-'. i.e. 766.
Also, a regex expression to extract 1 and 2 from JWE-766.1.pdf and JWE-766.2.pdf respectively.
Any help would be ...
Is there an easy way to capture types? I can't seem to do basic things like use variable expressions side by side, such as $mapType$$mapEnd$ to do a simple replacement. Is there any reason this might be? That is, if I have a single expression, say .*\s*.*abc, and I break it into two variables, .*\s* and .*abc, the expression does not mat...