i'm using the following to verify if a URL is formatted validly:
validates_format_of :website, :with => URI::regexp(%w(http https))
however, it doesn't work when the url doesn't start with http:// or https://. Is there some similar way to validate URLs with URI::regexp (or URI) and make it include valid URLs that don't start with http...
Hi everyone,
I have problem with regex.
I need to make regex with an exception of a set of specified words, for example: apple, orange, juice.
and given these words, it will match everything except those words above.
apple (should not match)
applejuice (match)
yummyjuice (match)
yummy-apple-juice (match)
orangeapplejuice (match)
orang...
hi i'm having this html markup
<body>
<table border="0" width="50%" align="center">
<tr>
<td>
<center>
and i'm trying to find a "wildcard" for the linebreaks to reach the <center> tag - how would this work?
thx
...
In javascript you can match regular expression with regex(string) syntax.
However the syntax isn't very used as far as I know, anybody know why?
...
I have been fighting this problem with the help of a RegEx cheat sheet, trying to figure out how to do this, but I give up... I have this lengthy file open in Notepad++ and would like to remove all lines that do not start with a digit (0..9). I would use the Find/Replace functionality of N++. I am only mentioning this as I am not sure wh...
Hi mates,
Really got stuck on this simple regex. Need it to validate a string, that will be a mail without the "@domain.xxx".
It must accomplish the following rules:
there must be a string (only letters) starting.
there must be a string (only letters) ending.
this two strings must be separated by a dot.
the complete string mustn't co...
some text i dont care about, some_text_I_want,
<bunch of spaces> some_text_I_want,
I want my pattern to match second line, not first line. Basically wherever some_text_I_want, is not preceeded with a ,
...
alert('test1');
var re = new RegExp("(http://(?:[A-Za-z0-9-]+\\.)?[A-Za-z0-9-]+\\.[A-Za-z0-9-]+/?)", "si");
alert('test2');
Why is this happening? How to solve this problem?
...
I'm writing a trimming function that takes a string and finds the first newline \n character after the 500th character and returns a string up to the newline. Basically, if there are \n at indices of 200, 400, and 600, I want the function to return the first 600 characters of the string (not including the \n).
I tried:
$output = preg_r...
Hello,
This is my first experience with C# and part of my limited experience with regular expressions and I'm having trouble capturing the first occurrence of a match in a particular expression. I believe the following example would make it more clear than words in describing what I want to do.
Match extractor = (new Regex(@".*\d(?<nam...
I have a large script that end-users need to edit so it requires somewhat redundant commenting. I use a layout for my files similar to this
//********************
//
// FileName
// This script contains:
// - Function X - does something
// - Function Y - does something else
//
//********************
//********************
// Fu...
I'm looking for a quick way (in C#) to determine if a string is a valid variable name. My first intuition is to whip up some regex to do it, but I'm wondering if there's a better way to do it. Like maybe some kind of a secret method hidden deep somewhere called IsThisAValidVariableName(string name), or some other slick way to do it tha...
I'm awful at regexes, but would love some help defining a rule that would take this text:
Il Cuccio, via Ronchi 43/b, 14047 Mombercelli, Asti.
Tel: 380 7277050 Fax: 0141 959282 E-mail: [email protected] www.ilcuccio.it
Accommodation in communal room or tent. French and English
spoken. Contact: Cristina Belotti.
Apicoltura Leida Bar...
Currently i'm using this reg exp:
var valid = (value.match(/^\d+$/));
But for digits like '0.40', or '2.43' this doesn't work. How can I change that reg exp above to match floats as well?
...
Hi,
I want to get a user input from user in a textbox, but i need to validate it
1.It should not take more than 7 digits before decimel
2.it should not take more than 3 digits after decimel
I actually figured out the 2nd part,,but first part is still a problem
my regular expression is:
/^([0-9]{0,7})+(\.[0-9]{1,3})?$/
Tell me whe...
Hi all,
I am getting a string "test+test1+asd.txt" and i want to convert it into "test test1 asd.txt"
I am trying to use function str = str.replace("/+/g"," ");
but this is not working
regards,
hemant
...
What's the shortest regex that can match non-zero floating point numbers with any number of decimal places?
It should accept numbers like
-1
-5.9652
-7.00002
-0.8
-0.0500
-0.58000
0.01
0.000005
0.9900
5
7.5
7.005
but reject constructions such as
.
.02
-.
-.996
0
-0
0.
-0.
-0.000
0.00
--
..
+
+0
+1
+.
+1.26
,etc
I do not need suppo...
Hi All,
I am wanting to create a regular expression for the following scenario:
If a string contains the percentage character (%) then it can only contain the following: %20, and cannot be preceded by another '%'.
So if there was for instance, %25 it would be rejected. For instance, the following string would be valid:
http://www.tes...
Hi all,
I'm getting strange kind of spam, where the email body only contains this:
4606142 5801100 2704743
How can I grep this with regex?
It's 3x7 numbers, separated with space.
thx
...
Perl and some other current regex engines support Unicode properties, such as the category, in a regex. E.g. in Perl you can use \p{Ll} to match an arbitrary lower-case letter, or p{Zs} for any space separator. I don't see support for this in either the 2.x nor 3.x lines of Python (with due regrets). Is anybody aware of a good strategy t...