So I have some text that I need to get an integer out of. Here's some examples of what the text could look like:
as low as $99
you can get it for $99 or less
I need to get the number out of the text, either with or without the $ sign.
Can I do this using Regex.Replace?
...
Hi,
how do I strip off all white space and ?
I have this as a input in a wrapper I create,
[b] bold [/b]
so before turning the text to bold, i want to strip off all white spaces and  , and turn it into [b]bold[/b],
$this->content = preg_replace("/\[(.*?)\]\s\s+(.*?)\s\s+\[\/(.*?)\]...
I'm using the following rule in jquery validate to make a name field, called nombre, only accept letters.
jQuery.validator.addMethod("nombre", function(value, element, param) {
return jQuery.trim(value).match(new RegExp("^(?:" + param + ")$"));
});
$("#nombre").rules("add", { nombre: "[a-zA-Z]+"})
I want the regex to ac...
What is the difference between encasing part of a regular expression in () (parentheses) and doing it in [] (square brackets)?
How does this:
[a-z0-9]
differ from this:
(a-z0-9)
?
...
UPDATE
Here is what I came up with. I haven't tested it yet because it is part of a much larger piece of code that still needs to be ported.
Can you see anything that looks out of place?
private const string tempUserBlock = "%%%COMPRESS~USER{0}~{1}%%%";
string html = "some html";
int p = 0;
var userBlock = new ArrayList();
MatchColle...
Hello
Can someone explain to me why the result from the following statement has a count of two an not just one?
MatchCollection matches = new Regex( ".*" ).Matches( "foo" ) ;
Assert.AreEqual( 1, matches.Count ) ; // will fail!
new Regex( ".+" ).Matches( "foo" ) ; // returns one match (as expected)
new Regex( ".*" ).Matches( "" ) ; // ...
I'm using PWD to get the present working directory. Is there a SED or regex that I can use to, say, get the full path two parents up?
...
When I split the string "1|2|3|4" using the String.split("|") I get 8 elements in the array instead of 4. If I use "\\|" the result is proper. I am guessing this has something todo with regular expressions. Can anybody explain this?
...
I am using the following Regular Expresion to remove html tags from a string. It works except I leave the closing tag. If I attempt to remove: <a href="blah">blah</a> it leaves the <a/>.
I do not know Regular Expression syntax at all and fumbled through this. Can someone with RegEx knowledge please provide me with a pattern that will...
This is about the code editor Notepad++.
I'm looking for a regular expression that will solve the following problem:
I have a set of html files. I need to find all links in them that are not links to javascript functions. If I search for the string 'href="' I get 342 results and if I search for 'href="javascript' I get 301 results. I'd...
I'm trying to match
<!-- Start Comment
content spanning several lines here
End Comment -->
And I figured something like this would do the trick:
(<!-- Start Comment).*(End Comment -->)
but the . is not matching newlines. How do I get it to recognize my entire block which contains a host of different characters including newline...
I want to do a REGEXP match with MySQL against a variable, like so:
SELECT *
FROM table
WHERE table.CONTENT
REGEXP CONCAT('([[:space:]]|[[:punct:]])', table.NAME, '([[:space:]]|[[:punct:]])')
This works fine, but it's possible for table.NAME to have regexp special characters in it (e.g. '|'), in which case it gets all screwed u...
I have a HUGE html which has many things I don't need, but inside it has URLs that are provided in the following format:
<a href="http://www.retailmenot.com/" class=l
I'm trying to extract the URLs... I tried, to no avail:
open(FILE,"<","HTML.htm") or die "$!";
my @str = <FILE>;
my @matches = grep { m/a href="(.+?") class=l/ } @str
...
New to js here. Basically I am trying to detect the existence of a string in the present page's url with this:
var url = window.location;
var param = /\?provider=/i;
if (url.search(param) != -1) {
alert('it does exist');
} else
alert('it does not exist');
It works when I manually define the url variable like so
var url = 'htt...
$text = 'something here *ls67 another thing'; // match
$text2 = 'something here *ls67. another thing'; // match
$text3 = 'something here another thing *ls67.'; // match
$text3 = 'something here another thing *ls67'; // doesn't match (and i need to match this)
$pattern = '|^(.*)?(\*[0-9a-zA-Z_-]{3,15})([^0-9a-zA-Z_-])+(.*)?$|i';
I've...
I get some URL from a XML feed. Now the question is how do I get a specific data from each page represented by those URLs.
For example if I have a URL: www.abc.com in the feed data and on that page there is a table like this:
<table>
<body>
<tr>
<td class="snip">
<span class="summary">
abc ... abc & xyz ...
<br>
..........
I was working on creating a regex which will include all patterns except 'time', 'hour', 'minute'
so, worked this out:
^(?:(?!time).)*$
how do i add for the other 2 words also? I tried as follows but it is incorrect.
^(?:(?![time][hour][minute]).)*$
Is there a better way to do this?
I am not adding the values which can be accepted...
If I do this:
var string = "7,11,2"
var check = string.match("/1/");
if(check != null){
doSomething();
} else {
doSomethingElse();
}
Then check is not null because match has found 1 in 11. So how should I avoid this and get 1 when it really appears?
...
Why is this giving me null?
<script language="javascript">
var element = "11";
var string = "7,11";
var check = string.match("/(^|\D)"+element+"(\D|$)/g");
alert(check);
</script>
When I run the regex on http://regex.larsolavtorvik.com/ it works correctly.
Pleeeease help I want to sleeeep! :))
...
I have a bunch of tweets that are returned as plain text that I would like to go through and assign proper links tags to based on RegEx matches.
As an example here is a tweet where I would like @Bundlehunt to become <a href="http://twitter.com/bundlehunt">@Bundlehunt</a> and the http://bundlehunt.com should become <a href="http...