I am checking a field if it is Latin Characters or not.
var foreignCharacters = $("#foreign_characters").val();
var rlatins = /[\u0000-\u007f]/;
if (rlatins.test(foreignCharacters)) {
alert("This is Latin Characters");
} else {
alert("This is non-latin Characters");
}
This works well, but I would like to change it so when I ...
Hi all,
i have to validate the data contains numeric or not and if it is not numeric return 0 and if it is numeric or empty return 1.
Below is my query i tried in SQL.
SELECT dbo.Regex('^[0-9]','123') -- This is returning 1.
SELECT dbo.Regex('^[0-9]','') -- this is not returning 1 but i want to return as 1 and i try to put space i...
I have an interesting problem. I wrote the following perl script to recursively loop through a directory and in all html files for img/script/a tags do the following:
Convert the entire url to lowercase
Replace spaces and %20 with underscores
The script works great except when an image tag in wrapped with an anchor tag. Is there a wa...
i want to how to get separate text from group of contents in java..
example
String a = "area href=\"hai.com\" jkjfkjs </area> ndkjfkjsdfj dfjkdsjfl jkdf dljflsd fljdf kd;fsd a href=\"hoo.com\" sdf</a> jisdjfi jdojfis joij";
i would like to get href link only..
how to write regex..
thanks and advance
...
I found a script which has the following snippet:-
userid=`expr "\`id\`" : ".*uid=[0-9]*(\(.[0-9a-z]*\)) .*"`
It returns the userid.
When i tried to learn how it is doing:-
#id
#uid=11008(adilm) gid=1200(cvs),1400(build)
So I realized that (.[0-9a-z]*) is matching the userid. But if I placed like below:
#userid=`expr "uid=11008(A...
While doing some small regex task I came upon this problem. I have a string that is a list of tags that looks e.g like this:
foo,bar,qux,garp,wobble,thud
What I needed to do was to check if a certain tag, e.g. 'garp' was in this list. (What it finally matches is not really important, just if there is a match or not.)
My first and a...
Is it possible to extract the nth match in a string of single-quoted words?
use strict;
use warnings;
my $string1 = "'I want to' 'extract the word' 'Perl','from this string'";
my $string2 = "'What about','getting','Perl','from','here','?'";
sub extract_quoted {
my ($string, $index) = @_;
my ($wanted) = $string =~ /some_regex...
This is JavaScript regex.
regex = /(http:\/\/[^\s]*)/g;
text = "I have http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd and I like http://google.com a lot";
matches = text.match(regex);
console.log(matches);
I get both the urls in the result. However I want to eliminate all the urls ending with .dtd . How do I do that?
N...
we have this code:
$value = preg_replace("/[^\w]/", '', $value);
where $value is in utf-8. After this transformation first byte of multibyte characters is stripped. How to make \w cover UTF-8 chars completely?
Sorry, i am not very well in PHP
...
Hey Guys
I am trying to remove all the relative image path slashes from a chunk of HTML that contains several other elements.
For example
<img src="../../../../images/upload/1/test.jpg />
would need to become
<img src="http://s3.amazonaws.com/website/images/upload/1/test.jpg" />
I was thinking of writing this as a rails helper, a...
This is what i want to do:
$line = 'blabla translate("test") blabla';
$line = preg_replace("/(.*?)translate\((.*?)\)(.*?)/","$1".translate("$2")."$3",$line);
So the result should be that translate("test") is replaced with the translation of "test".
The problem is that translate("$2") passes the string "$2" to the translate function. ...
I have the following code:
$postcode = $form->createElement('text', 'postcode');
$postcode->setLabel('Post code:');
$postcode->addValidator('regex', false,
array('/^[a-z]{1,3}[0-9]{1,3} ?[0-9]{1,3}[a-z]{1,3}$/i'));
$postcode->addFilters(array('StringToUpper'));
$postcode->setRequired(true);
It creates an in...
Is there a way in Python to access match groups without explicitely creating a match object (or another way to beautify the example below)?
Here is an example to clarify my motivation for the question:
Following perl code
if ($statement =~ /I love (\w+)/) {
print "He loves $1\n";
}
elsif ($statement =~ /Ich liebe (\w+)/) {
pri...
Is there a way to execute a SQL statement in SQLite to remove all the html from a TEXT field?
...
This works:
var.replace(/[^0-9]+/g, '');
That simple snippet will replace anything that is not a number with nothing.
But decimals are real too. So, I'm trying to figure out how to include a period.
I'm sure it's really simple, but my tests aren't working.
...
Here is my problem:
Create a constructor for a telephone number given a string in the form xxx-xxx-xxxx or xxx-xxxx for a local number. Throw an exception if the format is not valid.
So I was thinking to validate it using a regular expression, but I don't know if I'm doing it correctly. Also what kind of exception would I have to throw...
Hi all
i have below code
$name = new Zend_Form_Element_Text('name');
$validator = new Zend_Validate_Db_NoRecordExists('clients', 'name');
$validator->setMessage('A record already exists');
$name->addValidator($validator);
$name->setLabel('Name');
$name->setRequired();
$name->setDecorators($decorator->elementDecorators);
if i enter ab...
Following up from an earlier question on extracting the n'th regex match, I now need to substitute the match, if found.
I thought that I could define the extraction subroutine and call it in the substitution with the /e modifier. I was obviously wrong (admittedly, I had an XY problem).
use strict;
use warnings;
sub extract_quoted { # ...
I have a NetBeans project and the Mercurial repository is in the project root. I would like it to ignore everything except the contents of the "src" and "test" folders, and .hgignore itself.
I'm not familiar with regular expressions and can't come up with one that will do that.
The ones I tried:
(?!src/.*)
(?!test/.*)
(?!^.hgignore)...
I have data with dates written as 1992.09.02, as an example. If the dates are not available, you end up with 1992.09.?? or 1992.??.?? or otherwise .??.??.?? if no date is known.
I need to change the ".??" to "" ie., nothing.
Here's is my attempt, but I'm not getting anywhere.
$text="^[1-9]. [\.\?\?] ";
str_replace("\.\?\?", " ", "...