How do I split on all nonalphanumeric characters, EXCEPT the apostrophe?
re.split('\W+',text)
works, but will also split on apostrophes. How do I add an exception to this rule?
Thanks!
I want to have a function which gets a text as the input and gives back the text with URLs made to HTML links as the output.
My draft is as follows:
function autoLink($text) {
return preg_replace('/https?:\/\/[\S]+/i', '<a href="\0">\0</a>', $text);
}
But this doesn't work properly.
For the input text which contains ...
…
Hello. I'm using this regular expression for detect if an url ends with a jpg :
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]*^\.jpg)/ig;
it detects the url : e.g. http://www.blabla.com/sdsd.jpg
but now i want to detect that the url doesn't ends with an jpg extension, i try with this :
var…
Hi,
May I know the reason of getting the output of the following code as: 1,10,10? Why not it is as: 10, 10?
<script type="text/javascript">
var str="1, 100 or 1000?";
var patt1=/10?/g;
document.write(str.match(patt1));
</script>
Input:
hello world "22" bye world
I need a regex that will work in bash that can get me the numbers between the quotes. The regex should match 22.
Thanks!
When validating an email address with the regex validation component, an additional RequiredFieldValidator must be added to ensure there is a value present.
I've mostly taken care of this with a CustomFieldValidator, and taking care of this with Javascript.
Is there a better way of doing this?
Hi,
I'm writing a bash script that will show me what TV programs to watch today, it will get this information from a text file.
The text is in the following format:
Monday:
Family Guy (2nd May)
Tuesday:
House
The Big Bang Theory (3rd May)
Wednesday:
The Bill
NCIS
NCIS LA (27th April)
Thursday:
South Park
Friday:
FlashForward
Saturday:…
Hi,
I have this code, it looks alright and is really basic, but i can't make it work:
function checkValid(elem){
var abc = elem.value;
var re = "/[0-9]/";
var match = re.test(abc);
alert(match);
}
It matches 0 and 9, but not 1 to 8, what's wrong here? Thanks.
So, i have this :
"( ABC,2004 )"
And I would need to extract ABC in a variable and 2004 in another.
So what I have for now is this:
In: re.compile(r'([^)]*,').findall("(
ABC,2004 )")
Out: ['( ABC,']
Hello,
how could I remove all charakters from a string that aren't a-z/A-Z and 0-9 and _ with PHP?
I tried that but it has no effect, it returns the same string back:
preg_replace('[^a-zA-Z0-9_]', '', 'Testdo123_-:=)§%&');
I'm trying to add anchors to all h2's in my html, using python. This code will add those anchors, but I need to fill the name of the anchors too.
Any idea if the name can be the number of the match in the loop or a slugified version of the text between the h2 tags?
Here's the code so far:
regex =…
I have a webpage with an input field where only digits are allowed.
The input field has an onkeyup event that starts this validating function:
function validate() {
var uah_amount = document.getElementById("UAH").value;
var allowed = /^\d+$/;
document.getElementById("error").innerHTML =…
I'm trying to parse an HTML file and get all href's inside it.
So far, the code I'm using is:
(map
#(println (str "Match: " %))
(re-find #"(?sm)href=\"([a-zA-Z.:/]+)\"" str_response))
str_response being the string with the HTML code inside it. According to my basic understanding of…
I'm trying to perform regex to match a fraction.
The user will input a fraction eg., 1/4, 1 1/2 10/2 so on.
I have tested this regex and it works, but the problem is when I type in 10, 20, 30, 40 so on It does not recognized these values. This is my regex As you can see, it first sorted out…
I have the following string examples:
00001 1 12 123
00002 3 7 321
00003 99 23 332
00004 192 50 912
In a separate text file. Numbers are separated by tabs not spaces.
I tried to read the file and print each line if it matches a given RegExp, but I could not find the suitable RegExp for…
In my web app I've got a form field where the user can enter an URL. I'm already doing some preliminary client-side validation and I was wondering if I could use a regexp to validate if the entered string is a valid URL. So, two questions:
Is it safe to do this with a regexp? A URL is a…
Hi!
I got this url
/search/renttype-all.place-all.type-all.bedrooms-all.0.0/
I want to get the text after the second "/" and the third "/". The URL can end at the third "/" or go on with more text and "/". I have been trying with a lot of rules but never got any to work. My last try…
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.
Hello, I chose this way to get linux distro name:
ls /etc/*release
And now I have to parse it for name:
/etc/<name>-release
def checkDistro():
p = Popen('ls /etc/*release' , shell = True, stdout = PIPE)
distroRelease = p.stdout.read()
distroName = re.search(…
Hello guys, I have such text:
<Neednt@email.com> If you do so, please include this problem report.
<Anotherneednt@email.com> You can delete your
own
text from the attached returned message.
The mail system
<Some@Mail.net>:…
I am trying to perform some composition-based filtering on a large collection of strings (protein sequences).
I wrote a group of three subroutines in order to take care of it, but I'm running into trouble in two ways - one minor, one major. The minor trouble is that when I…
Hello, I have to get any text between:
Final-Recipient: RFC822; !HERE! Action
I need !HERE! from this example. There could be any string.
I tried something like:
$Pattern = '/Final-Recipient: RFC822; (.*) Action/';
But it doesn't work.
upd
Here is the string I'm…
I have used regExp quit a bit of times but still far from being an expert. This time I want to validate a formula (or math expression) by regExp. The difficult part here is to validate proper starting and ending parentheses with in the formula.
I believe, there would be…