The string can have Alphabets [a-zA-Z]
It can have numbers [0-9] but min 0 and max 2
spaces are allowed
And for special characters max 1 hyphen, and max 1 comma
...
Hello,
I tried writing a program in Java using regex to match a pattern and extract it. Given a string like "This is a link- #www.google.com# and this is another #google.com#" I should be able to get #www.google.com# and #google.com# strings extracted. Here is what I tried-
import java.util.regex.Matcher;
import java.util.regex.Pattern...
I need to use a RegEx to set an upper boundry for the length of an input string.
Its been ages since I used RegEx so any help would be good. :)
...
I'm using selenium RC and I would like, for example, to get all the links elements with attribute href that match:
http://[^/]*\d+com
I would like to use:
sel.get_attribute( '//a[regx:match(@href, "http://[^/]*\d+.com")]/@name' )
which would return a list of the name attribute of all the links that match the regex.
(or something li...
I have a problem regarding display PHP code (stored in a database) on a website.
This is the text I have in the database:
Blah Blah Blah this is regular text
[code]
<?php
$message = \"<div class=\'code\' style=\\\"NO\\\">\";
echo $message;
?>
[/code]
Blah Blah Blah this is more regular text
Which I want to display as:
Blah Blah ...
In perl, if I have a string $str and a pattern saved in $pat and I want to replace what is saved in $pat with 'nothing' only if $pat appears at the end of $str, how would the regular expression look like? I tried different versions of this - s/\$pat$//
That, and all variations( s/$pat$//, s/\${pat}$//, s/${pat}$//) are not working :|
...
Public ReadOnly Property IsAlphaNumeric(ByVal entry As String) As Boolean
Get
Return New Regex("(?!^[0-9]*$)(?!^[a-zα-ωA-ZΑ-Ω]*$)^([a-zα-ωA-ZΑ-Ω0-9]{6,15})$", RegexOptions.IgnoreCase).IsMatch(entry)
End Get
End Property
This one is pretty good for Greek and English language.
What about all the other languages in the universe?
S...
According to the documentation of java.util.Pattern, the POSIX character class \p{Graph} ([:graph:] in POSIX notation) matches "a visible character: [\p{Alnum}\p{Punct}]". However, this is limited to ASCII characters only. Is there an equivalent class or expression for matching (visible) Unicode characters?
...
Ok I have to parse out a SOAP request and in the request some of the values are passed with (or inside) a Anchor tag. Looking for a RegEx (or alt method) to strip the tag and just return the value.
// But item needs to be a RegEx of some sort, it's a field right now
if($sObject->list == 'item') {
// Split on > this should be the end ...
I find the regular expression toolkit tool in Komodo 4.1 pretty handy. Trouble is you have to dish out $300 for Komodo to use it. I'd love the same functionality in a stand alone tool... any suggestions?
...
Hi,
I've this regex: ^[\p{L}\p{N}]{1,50}$
Accept all numbers and all letters
min length: 1
max length: 50
I'm trying to add this rule without success:
can add \s (spaces) but the text can not have only empty spaces
...
Hello
I'm trying to make a pattern for tags, but the sub method just replace the first char and 3 at the end of the line, im trying to replace all tags on the line and with multiline
p=re.compile('<img=([^}]*)>([^}]*)</img>', re.S)
p.sub(r'[img=\1]\2[/img]','<img="test">dsad</img> <img="test2">dsad2</img>')
output:
'**[**img="test">dsa...
I have an array:
var locations = ['Afghanistan','Albania','Algeria','New York'];
and a string:
var string = 'I love Afghanistan New York Afghanistan Andorra Andorra Algeria New York';
I want to count the number of times each keyword in the array appears in the string but can't figure out the best way to do that.
...
So I need to get hours, minutes and seconds out of entries like these:
04:43:12
9.43.12
1:00
01.04
59
09
The first two is hours, minutes and seconds.
Next to is minutes and seconds.
Last two is just seconds.
And I came up with this regexp, that works..:
\A(?<hours>\d{1,2})(?::|\.)(?<minutes>\d{1,2})(?::|\.)(?<seconds>\d{1,2})\z|...
I have the following line:
hshd household 8/29/2007 LB
I want to match anything that comes before the first space (whitespace). So, in this case, I want to get back
hshd
...
I have a search method that takes in a user-entered string, splits it at each space character and then proceeds to find matches based on the list of separated terms:
string[] terms = searchTerms.ToLower().Trim().Split( ' ' );
Now I have been given a further requirement: to be able to search for phrases via double quote delimiters a la...
I am trying to get the first word in the line that matches the whole word 'number'. But I am only interested where whole word 'number' is matched and is preceded by a tab.
For example if following is the text:
tin identification number 4/10/2007 LB
num number 9/27/2006 PAT
I want to get back num
Regex I have is:
match whole word...
Hey Folks,
I am entirely new to regex, and am trying to use it to match vales in order to map them to variables (javascript looking at the output in responceText generated from a php script).
At the moment I have this code:
if (xmlhttp.readyState==4)
{
document.getElementById("test").innerHTML=xmlhttp.responseText;
cmake = xmlh...
How to use gsub with more than 9 backreferences?
I would expect the output in the example below to be "e, g, i, j, o".
> test <- "abcdefghijklmnop"
> gsub("(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)(\\w)", "\\5, \\7, \\9, \\10, \\15", test, perl = TRUE)
[1] "e, g, i, a0, a5"
...
I have written a PHP function to take a video embed code that has width and a height and allow you to specify a new width. The function will then scale down the height using the appropriate scaling factor. I discovered that the width and height were not always adjacent so I make a couple of calls which I have a hunch are unnecessary. Is...