Let's say I have a variable called URL and it's assigned a value of http://www.google.com. I can also received the URL via ftp, hence it'll be ftp://ftp.google.com. How can I have it so I grab everything before the :? I'll have an if/else condition afterwards to test the logic.
...
I'm going to validate simple math expressions such these:
a = 1 + 2
b = 2.2
a = b + 5.5
a = b - -5.5
a = -1 + 2
a = -2.4
a = 3.5 / 0.2 + 1
a = 3 * -2.1
NOTE: Operator precedence is not important!
I try following expressions but i got nothing!!!
for digits: ^([-]|[.]|[-.]|[0-9])[0-9]*[.]*[0-9]+$
for operators: [-]|[+]|[*]|[/]
for var...
I'm attempting to make a function in PHP that will evaluate a mathematical expression -- including functions such as sin, cos, etc. My approach is to delete all characters in the phrase that are not numbers, mathematical operators, or mathematical functions and then use that string in an eval(). The problem is that I don't know enough ...
I have many lines containing the names of US Presidents Carter, Bush, Clinton, Obama. Some contain 1 of those names, some 2, some 3, some all 4 of them (in any order)
I know how to search for Carter AND Clinton AND Obama -> :g/.*Carter\&.*Clinton\&.*Obama/p ;
I know how to search for Carter AND (Clinton OR Bush) -> :g/.*Carter\&(.*Cli...
Hi, i tried to do not show "SPAM" in string below using that regex:
alert("{SPAM\nSPAM} _1_ {SPAM} _2_".replace(/{[\s\S]+}/gm, ""));
What i was supposed to see was "~1~ ~2~"
(or something like that) but i got just ~2~. Why?
...
Hi,
Was wondering how I would extrapolate the value of an html element using a regular expression (in python preferably).
For example, <a href="http://google.com"> Hello World! </a>
What regex would I use to extract Hello World! from the above html?
Thanks in advance,
James Eggers.
...
Hi,
This might be a piece of cake for java experts. Please help me out:
I have a block of comments in my program like this:
/*********
block of comments - line 1
line 2
.....
***/
How could I retrieve "block of comments" using regex?
thanks.
...
I am trying to split a string into an array of word pairs in PHP. So for example if you have the input string:
"split this string into word pairs please"
the output array should look like
Array (
[0] => split this
[1] => this string
[2] => string into
[3] => into word
[4] => word pairs
[5] => pairs please
...
Problem
There is a program file that contains the following code snippet at some point in the file.
...
food($apples$ , $oranges$ , $pears$ , $tomato$){
...
}
...
This function may contain any number of parameters but they must be strings separated by commas. All the parameter strings are lowercase words.
I want to be able to pa...
If there is one that could handle this, what would be the correct regex pattern to extract email addresses from a string coming from an email form "To" line, that allows the addresses to be delimited by commas ",", semicolons ";", spaces, or any combination of the three. The regex also has to be able to ignore "noise" text, such as if an...
Hello,
I don't have much experience with RegEx so I am using many chained String.Replace() calls to remove unwanted characters -- is there a RegEx I can write to streamline this?
string messyText = GetText();
messyText.Trim().ToUpper().Replace(",", "").Replace(":", "").Replace(".", "").Replace(";", "").Replace("/", "").Replace("\\", ""...
I am learning regex (http://www.regular-expressions.info/), and trying to figure out how to match the part of the following string that is not: a word containing a q that is not followed by a u.
I've gotten this far, but cannot figure out how to reverse it properly. This regex is successful in finding the word. Now, I just need to figur...
I have the following line in my Emacs init file.
(global-set-key (kbd "C-x a r") 'align-regexp)
Is there any way to hard-code in a particular regex so that I don't have to specify it every time?
...
In IRB, I can do this:
c = /(\b\w+\b)\W*(\b\w+\b)\W*(\b\w+\b)\W*/.match(" !!one** *two* @@three@@ ")
And get this:
=> MatchData "one** *two* @@three@@ " 1:"one" 2:"two" 3:"three"
But assuming I don't know the number of words in advance, how can I still extract all words out of the string". For example, it might be " !!one** *two* @@...
How if at all can I use regex to match a string with a variable number of matches.
The strings I want to parse look like:
'Every 15th of the month'
'Every 21st and 28th of the month'
'Every 21st, 22nd and 28th of the month'
ad infinitum...
I want to be able to capture the ordinal numbers (15th, 21st etc)
The language I'm using is R...
I'm trying to match my grammar to an entire string, and have it error out if it cannot consume the entire input. Basically, this pseudo regex:
\whitespace* [a-zA-Z]+ [-]? [a-zA-Z]+ \whitespace* $
According to this, EOF should work. So, consider this grammar:
start : CHARS EOF
;
CHARS : ('a'..'z')+
;
If I set input t...
Greetings All,
I need to optimize a RegEx I am using to parse template tags in my CMS. A tag can be either a single tag or a matching pair. An example of some tags:
{static:input:title type="input"}
{static:image:picture}<img src="{$img.src}" width="{$img.width}" height="{$img.height"} />{/static:image:picture}
Here is the RegEx I...
Hi, I am trying to program a email piping php script that would take an incoming traffic update report via email, and extract the relevant information within it to store into a database.
The email usually starts with some introduction, with the important information displayed in the following format.
Highway : Some Highway
Time : 08...
Ok, here is my test (this is not production code, but just a test to illustrate my problem)
my $string = <<EOS; # auto generated query
SELECT
users.*
, roles.label AS role_label
, hr_orders.position_label
, deps.label AS dep_l...
Hi,
I'm frustrated with composing regular expressions for Matching "ABAB", "AABB", "ABB", "AAB", "ABAC" and "ABCB".
Let's take "ABAB" for example, all the following string will be matched:
abab
bcbc
1212
xyxy
9090
0909
Which means the RegEx should match a string whose 1st and 3rd characters are same, and 2nd and 4th are also same, b...