Regular and Irregular Expressions Regular expressions are a powerful form of declarative programming languages, mainly used for pattern matching within strings. Their corresponding machine model is the finite automaton. There are many different dialects of regular expressions, all subtly ...
1
vote
2answers
12 views
1
vote
2answers
26 views
Problems with building this regex [1,2,3]
i have a problem to build following regex:
[1,2,3,4]
i found a work-around, but i think its ugly
String stringIds = [1,2,3,4];
stringIds = stringIds.replaceAll("\\[", "");
stringIds = ...
1
vote
1answer
12 views
Validating an input field with two conditions
I have this HTML field:
<input type="text" name="userInput" id="userInput">
I want to make sure that the user enters either at least five characters or nothing at all.
This code, which only ...
-4
votes
2answers
17 views
Special Character check using Java Pattern
I want to generate Two patterns with below information,
1)The following special characters cannot be entered in the first name, last name, email, phone number fields in the Account form:
Pattern " ...
0
votes
2answers
16 views
Rewrite a URL to include GET data (with Drupal)
I'm relatively new to both .htaccess and regular expressions, but I really need to do the following. I'm using Drupal for my website (I don't know if the affects anything) but I've wrote a small PHP ...
0
votes
2answers
23 views
Regex to match any character except trailing spaces
I'm using this /\([^\S\n]*(.*)[^\S\n]*\)/ regex to match what is inside brackets, and it works good except when there are trailing spaces, it matches them.
In for example ( test1 test2 ) I would like ...
0
votes
2answers
35 views
Regular expression for finding a word
I have a long string of characters as input and I want to count the number of words in that string. How can I do it through regular expression?
0
votes
3answers
26 views
Using PCRE_MULTILINE with a caret
In a C code, I need to check if a pattern matches on at least one line of a file. I need a caret in my expression. What I have is:
const char *disambiguate_pp(SourceFile *sourcefile) {
char ...
-1
votes
3answers
35 views
Want regular expression for following?
i have :
<description><![CDATA[<div><b>Details:</b> <div class=ExternalClassCDAAC64F989B48B1AE79489DFBF8C27C><div><span ...
2
votes
5answers
53 views
Regex to match alphanumeric characters, underscore, periods and dash, allowing dot and dash only in the middle
Presently, I am using this:
if (preg_match ('/^[a-zA-Z0-9_]+([a-zA-Z0-9_]*[.-]?[a-zA-Z0-9_]*)*[a-zA-Z0-9_]+$/', $product) ) {
return true;
} else {
return false
}
For example, I want to match:
...
0
votes
3answers
22 views
How do I strip spaces & special characters from a string in specific positions? - Ruby
Say I have a string like this:
May 12 -
Where what I want to end up with is:
May 12
I tried doing a gsub(/\s+\W/, '') and that works to strip out the trailing space and the last hyphen.
But I am ...
1
vote
1answer
11 views
Match at start of line \d or \d\d
I am trying to match the start of these lines to get the number
1 - blah
01 - blah
I expect
1
01
I have this regex but dont understand why the second part is not matching 01
((^\d)|(^\d\d))
...
0
votes
1answer
11 views
htaccess rewrite condition and rewrite rule for redirecting to a page using a particular name having peroids
I have a link http://mysite.com/username which redirects to profile page of current
username..
My htaccess code for this link is :
RewriteCond %{REQUEST_URI} ^/(\w+)/?$ [NC]
RewriteRule ^ ...
-1
votes
6answers
41 views
Difference between * and + regex
Can anybody tell me the difference between the * and + operators in the example below:
[<>]+ [<>]*
0
votes
1answer
15 views
Sha 1 php, possible variations and regex
First,
Is it possible for a sha1 hash to be all numbers or letters,
And second is there any need for the start and end delimiters when using a regex to check for a sha 1 hash, ie,
/^[0-9a-f]{40}$/i
...