regex

regex to validate double values

Hi, I'm trying to come up with a regex to validate a double value. I will admit that I am crap at regex and really should buy a book... Anyway the range is large so here goes: .01 to 99.99, is the range, with the leading '00' being optional, as is the '.' and the same for the trailing '.00'. So the user could type in 0.1 00.01, 0.11...

replacing custom html tag in php

I have custom html tags in my apps, it looks like this: <wiki href="articletitle">Text</wiki> and want it replaced to be like this: <a href="http://myapps/page/articletitle"&gt;Text&lt;/a&gt;. How I can do that in PHP? ...

how to make vim show ^M and substitute it

my vim show tab as --->, but does not show windows ^M character. And , how substitute it in vim. renew ============ I check my vimrc it is set fileformat=unix but when I open a dos file set ff is dos ...

Replace a string on php

Hi All, I am using a function that converts INR to USD. I am using this function: function convertCurrency($from_Currency,$to_Currency,$amount) { $amount = urlencode($amount); $from_Currency = urlencode($from_Currency); $to_Currency = urlencode($to_Currency); $url = "http://www.google.com/ig/calculat...

Remove domain extension

So let's say I have just-a.domain.com,just-a-domain.info,just.a-domain.net how can I remove the extension .com,.net.info ... and I need the resultes in two variables one with the domain name and another one with the extension. I tried with str_replace but doesn't work, I guess only with regex....where I'm a noob. Can someone please hel...

How to "Validate" Human Names in CakePHP?

I have a PHP script that is supposed to check for "valid" human names, but recently cracked against a name with a space, so we added spaces to our validator. Rather than doing this, is there a way to add a blacklist to CakePHP's validator to block all "invalid" characters, rather than allowing "valid" ones? NOTE: I know how to do this...

preg_match question

hi, $page = $_GET['page']; if(isset($page)) if(!preg_match('/[\w\d_]+/i', $page)) die("Error"); I want to allow alphanum and underscore, above code works but let say i set 123..., this works too. Is preg_match will not validate behind entry? ...

Regex c# shouldnt match Boolean Operators

Hi, I'm trying to write a regex which should be able to identify boolean expressions. I need to avoid cases like IF(AND AND AND). The name of the variable shouldn't be one of the following operators (OR;AND;XOR). I tried to use [^(OR)] but this wasn't helpful. My Regex looks like this: (?:<Name> [A-Za-z0-9]) Is there any chance t...

Java regular expressions and dollar sign.

Hello, I have Java string: String b = "/feedback/com.school.edu.domain.feedback.Review$0/feedbackId"); I also have generated pattern against which I want to match this string: String pattern = "/feedback/com.school.edu.domain.feedback.Review$0(.)*"; When I say b.matches(pattern) it returns false. Now I know dollar sign is part of ...

parse text with Matlab

I have a text file (output from an old program) that I'd like to clean. Here's an example of the file contents. *|V|0|0|0|t|0|1|1|4|11|T4|H01|||||||||||||||||||||| P|40|0.01|10|1|1|0|40|1|1|1||1|*||0|0|0|||||||||||||||| *|A1|A1|A7|A16|F|F|F|F|F|F|F||||||||||||||||||||||| *|||||kV|kV|kV|MW|MVAR|S|S|||||||||||||||||||||||| N|I|01|H0...

Rails 3 routes with extended regex :constraints - bug?

I have the following route in my Rails 3 app. post 'games/:id/:task/:card_id' => 'games#perform', :as => :perform ...which allows, obviously, such requests as button_to("Foo", {card_id=>2, :action=>:perform, :task=>"foo"}), mapping to the URL /games/1/foo/2. I'd like to restrict the set of tasks the route matches. The Rails API docs ...

Goals in Google Analytics do not work

Hello I cannot figure out how to get Google Analytics Goals to work: URL in Google Analytics report: /relay/v2/relay.cgi/www.mydomain.com/faerdig.php?tid=3414528&orderid=03-14:29&amount=100000&cur=208&date=20101003&time=1430&cardnopostfix=4000&timer=03-14:29&cardid=2&transfee=0 (Above URL is taken straight from the Google Analytics r...

Url rewriting for Zeus - regex help

Hi, I've been landed with the unenviable task of putting a site live today only to find out its not running on Apache but instead is using Zeus. Now this breaks my mod_rewrite script rather messily. Its a simple script which I've rewrote into Zeus format: RewriteEngine on RewriteRule !404.php$ blog/404.php [L] becomes match URL in...

regex replace in middle

I trying to replace string "Resources.AppResource.Info;" like this "Switch("Info");" Is this possible with regex? ...

Removing XML-tag via regex

Greetings, I've read some threads about this topic, but actually I was unable to find or to think of a adequate solution (see for example: http://stackoverflow.com/questions/121656/regular-expression-to-remove-xml-tags-and-their-content). I have an xml tag like that: <bla_tag size="100" diameter="50" ratio="0.2" ...

Regular expressions: How do I grab a block of text using regex? (in ruby)

I'm using ruby and I'm trying to find a way to grab text in between the {start_grab_entries} and {end_grab_entries} like so: {start_grab_entries} i want to grab the text that you see here in the middle {end_grab_entries} Something like so: $1 => "i want to grab the text that you see here in the middle" So far, ...

How can I find javascript method names in a file?

Hi everyone, Can any one help me in finding the method names using regular expressions in javascript files. ...

How can I find the contents of the first h3 tag?

Hi, I am looking for a regex to find the contents of the first <h3> tag. What can I use there? ...

Regular Expression to select Filenames with exceptions

How do I select all files in a directory with exception of few files like file-1.php, file-2.php and file-3.php ? The exception file names can be anything like file-a.php, arbit-file-name.php or anything.jpg. Its not a sequential set of files like file-1 etc. ...

Regex: How do you capture one group among multiple groups using regex? (in ruby)

I have two groups of text: firstgroup (some content) endgroup secondgroup (some content) endgroup I'm trying to just capture the first group (not the second group). I'm using this regular expression: firstgroup(.|\n)*endgroup For some reason, that regular expressions selects both first group and second group (probably because it ...