I need regularexpression to match braces correct e.g for every open one close one
abc{abc{bc}xyz} I need it get all it from {abc{bc}xyz} not get {abc{bc} I tried this
({.*?})
In one of the StackOverflow Podcasts (the one where guys were discussing data generation for testing DBs -- either #11 or #12), Jeff mentioned something like "reverse regular expressions", which are used exactly for that purpose: given a regex, produce a string which will eventually match said regex.
What is the correct term for this whole concept? Is this a well-known concept?
I have this piece of code:
function func1(text) {
var pattern = /([\s\S]*?)(\<\?(?:attrib |if |else-if |else|end-if|search |for |end-for)[\s\S]*?\?\>)/g;
var result;
while (result = pattern.exec(text)) {
if (some condition) {
throw new Error('failed');
}
...
}
}
This works, unless the throw statement is executed. In that case, the next time I call the function, the exec() call starts where it left off, even though I am supplying it with a new value of 'text'.
I can fix it by writing
var pattern = new RegExp('.....');
instead, but I don't understand why the first version is failing. How is the regularexpression persisting between function calls? (This is happening in the latest versions of Firefox and Chrome.)
Edit Complete test case:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<title>Test Page</title>
<style type='text/css'>
body {
font-family: sans-serif;
}
#log p {
margin: 0;
padding: 0;
}
</style>
<script type='text/javascript'>
function func1(text, count) {
var pattern = /(one|two|three|four|five|six|seven|eight)/g;
log("func1");
var result;
while (result = pattern.exec(text)) {
log("result[0] = " + result[0] + ", pattern.index = " + pattern.index);
if (--count <= 0) {
throw "Error";
}
}
}
function go() {
try { func1("one two three four five six seven eight", 3); } catch (e) { }
try { func1("one two three four five six seven eight", 2); } catch (e) { }
try { func1("one two three four five six seven eight", 99); } catch (e) { }
try { func1("one two three four five six seven eight", 2); } catch (e) { }
}
function log(msg) {
var log = document.getElementById('log');
var p = document.createElement('p');
p.innerHTML = msg;
log.appendChild(p);
}
</script>
</head>
<body><div>
<input type='button' id='btnGo' value='Go' onclick='go();'>
<hr>
<div id='log'></div>
</div></body>
</html>
The regularexpression continues with 'four' as of the second call on FF and Chrome, not on IE7 or Opera.
I need a regular in expression in PHP that I can plug into preg_match_all and find if an @ sign and any character number or letter follows right after that. So if I put "@patrick hello there" it will come up true, if I put in "I saw her @ the mall" it will be false.
Thank you :)
Is it possible to draw a frame around an expression? For example if I presented a calculation, I want to draw attention to the result by drawing a "box" around it.
I've seen it done in some articles in LaTeX. Is it possible to do in LyX without ERT? Otherwise, how is it done in LaTeX?
Hi There,
Does anyone have a regurlar expression available which only accepts dates in the format dd/mm/yy but also has strict checking to make sure that the date is valid, including leap year support?
I am coding in vb.net and am struggling to work this one out.
Many Thanks
if i have this code today to find out a sum total using LINQ:
return (MyArray.Sum(r => r.Trips);
and i want to only include itms where r.CanDrive == true.
can you add a condition into a single linke lambda expression? how would you do this
Hi all,
I got a problem when I tried to find some characters with following code:
preg_match_all('/[\w\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A]/',$str,$match); //line 5
print_r($match);
And I got error as below:
Warning: preg_match_all() [function.preg-match-all]: Compilation failed: PCRE does not support \L, \l, \N, \U, or \u at offset 4 in E:\mycake\app\webroot\re.php on line 5
I'm not so familiar with reg expression and have no idea about this error.How can I fix this?Thanks.
For the love of God I am not getting this easy code to work! It is always alerting out "null" which means that the string does not match the expression.
var pattern = "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$";
function isEmailAddress(str) {
str = "[email protected]";
alert(str.match(pattern));
return str.match(pattern);
}
What will be proper regularexpression for git repositories?
example link:
[email protected]:someone/someproject.git
so it will be like
server can be url or ip
Project can contain some other characters than alphanumeric like '-'
I'm not sure what is the role of '/'
any suggestions?
I have some kind of "data engine" between multiple "data consumer" processes and multiple "data storage" sources. I'd like to provide Linq capabilities to the "data consumer" and forward the query to the "data storage". The forwarded query should be some structured query (like, let's say, NHibernate Criteria).
Is there any existing structured query library that could allow me to "just" translate a Linq Expression to such a structured query?
I need to change some characters that are not ASCII to '_'.
For example,
Tannh‰user - Tann_huser
If I use regularexpression with Python, how can I do this?
Is there better way to do this not using RE?
What will be the regularexpression in javascript to match a name field,
which allows only letters, apostrophes and hyphons?
so that jhon's avat-ar or Josh is valid?
Thanks
I need help on regularexpression on the condition (4) below:
Begin with a-z
End with a-z0-9
allow 3 special characters like ._-
The characters in (3) must be followed by alphanumeric characters, and it cannot be followed by any characters in (3) themselves.
Not sure how to do this. Any help is appreciated, with the sample and some explanations.
I know this may be the simplest question ever asked on Stack Overflow, but what is the regularexpression for a decimal with a precision of 2?
Valid examples:
123.12
2
56754
92929292929292.12
0.21
3.1
Invalid examples:
12.1232
2.23332
e666.76
Sorry for the lame question, but for the life of me I haven't been able to find anyone that can help!
The decimal place may be option, and that integers may also be included.
I am an amateur in JavaScript. I saw this other question, and it made me wonder.
Can you tell me what does the below regularexpression exactly mean?
split(/\|(?=\w=>)/)
Does it split the string with "|"?
How can i rewrite the below SQL query to its equivalent LINQ 2 SQL expression (both in C# and VB.NET)
SELECT t1.itemnmbr, t1.locncode,t1.bin,t2.Total
FROM IV00200 t1 (NOLOCK)
INNER JOIN
IV00112 t2 (NOLOCK)
ON t1.itemnmbr = t2.itemnmbr
AND t1.bin = t2.bin
AND t1.bin = 'MU7I336A80'
Can someone give me the regularexpression to match something like /this/is/the/path or /this/is/the/path/ and matches like:
$1=this
$2=is
$3=the
$4=path
([^/]+)/ matches one, but I'm not quite sure how to get it to repeat.
FYI: this is for a mod rewrite RewriteRule match.
Here's my code. It compiles in VS2005 but not in gcc. Any ideas
template<class T>
Derived<T>::Derived(const Derived<T>& in)
{
Base<T>::Base<T>(in); //ERROR here
}
"expected primary-expression before token"
If I try:
Groups = students.Remove(f => f.StudentID.Equals(studentID));
I get an error on this line: f => f.StudentID.Equals(studentID)
I am having difficulty from my previous posts here linq deleted users still associated with groups and here Delete method in WCF
So I thought maybe I could delete the students contained within groups but I get an error Cannot convert lamda expression to type Student because it is not a delegate type.
Does anyone know of a regularexpression for matching on a sequence of four numbers? I need a match on ascending (1234), descending (4321), or the same (1111).
The string is stored in a parameter.
Say, @FiscalPeriod = "[Date].[Fiscal Dates].[Fiscal Quarter]"
Now,
I need to use the parameter as
SELECT Measures.[Revenue] ON 0,
CLOSINGPERIOD("Parameter Here") ON 1
FROM [Sales]
STRTOMEBER function gives error because it is looking for a member at the leaf left such as
[Date].[Fiscal Dates].[Fiscal Quarter].&[Q1 - 2009]
How can I resolve the string into the mdx expression to use it with closing period??