regex

Arguments with regex

I would like to know how to split this string: command arg1 arg2 arg3 In this array: [arg1,arg2,arg3] BUT if the user types: command "arg1 still arg1" arg2 The array will be: [arg1 still arg1, arg2] Using PHP ...

jquery regular expression for a text area

I have a regular expression that returns us and canada zipcodes as follows. ((?<US>\d{5})|(?<Can>\b[A-Z-[DFIOQUWZ]]\d[A-Z-[DFIOQU]]\ +\d[A-Z-[DFIOQU]]\d\b)) I need to do this in java script or jquery. An application that can extract only these values. For example someone could simply paste a document into the textarea, click a butto...

How to match word where count of characters same

Hello Please help with below I need match only words where counting of characters same for example same counting for a b c abc ///match 1 (abc) aabbcc match 2(abc) adabb not mach 2(ab) ttt match 0(abc) ...

What is a regular expression for parsing out individual sentences?

I am looking for a good .NET regular expression that I can use for parsing out individual sentences from a body of text. It should be able to parse the following block of text into exactly 6 sentences: Hello world! How are you? I am fine. This is a difficult sentence because I use I.D. Newlines should also be accepted. Number...

PHP: RegEx vs. ctype_*

Dear all, several months ago, you provided a perfect solution for my IsAlpha & co issues. But once again, I ran into issues after upgrading PHP (to version 5.2.9), although the ctype_* functions seem to do their job now: ctype_alpha( $value ) /* VS */ preg_match("/^[\p{L} _.\-]+$/u", $value) ctype_alnum( $value ) /* VS */ preg_matc...

Regular Expression to split on specific character ONLY if that character is not in a pair

After finding the fastest string replace algorithm in this thread, I've been trying to modify one of them to suit my needs, particularly this one by gnibbler. I will explain the problem again here, and what issue I am having. Say I have a string that looks like this: str = "The &yquick &cbrown &bfox &Yjumps over the &ulazy dog" You'...

Regular Expressions Match Specific Location In File

The file i am working with (oraInst.loc) looks like this: inventory_loc=/u01/app/ORAENV/oracle/oraInventory inst_group=dba I need to use a regular expression to grab the value between app/ and /oracle. In this case it will be ORAENV but it could be any alphanumeric string of any case and length but with no spaces. From what I have re...

Regular Expression, C#

Hello there, I need help regarding Regular Expression to find a tag/code called 'WAITPHOTO' in a document text. Depending on the presence of WAITPHOTO tag, I will be wrapping text around an Image(left/right of image). FYI, All the tags starting with PHOTO will be replaced by Image at run-time. I have some text that looks like: Steps f...

What characters are allowed in a Google App Engine Key?

While testing my Google App Engine application, I search for links which include app engine keys. For example: /story/ag5yZXBsaWUtdGVzdGluZ3IMCxIFU3RvcnkY-w0M/ What characters are allowed in these keys? I had been using the regex [a-zA-Z0-9], but it seems "-" is also allowed. What else? Is there a reference on this? I can't find it i...

Search in sqlite table where column matches regex

Hi, I'm writing a web application in Rails which uses sqlite. I want the user to be able to search a table in the database by using a regex. Is this possible? Thanks. ...

why do these regex tests let certain characters pass?

I am checking a string with the following regexes: [a-zA-Z0-9]+ [A-Za-z]+ For some reason, the characters: . - _ are allowed to pass, why is that? ...

php regular expression

Hello guys i am trying to get the text inside specific <td's>. Each one has a id="uniqueName" - Such as: <td id="engineTypeField" class="normal2" colspan="2"> 3.0L L6 SFI DOHC</td> but i am having bad luck - learning regexp as doing so This is what i have: preg_match ("<td id='\/engineTypeField\/(.*)>(.*)</td>i", $result, $matches); /...

Want any alphanumeric and underscore, dash and period to pass

In my controller, I current set a constraint that has the following regex: @"\w+" I want to also allow for underscore,dash and period. THe more effecient the better since this is called allot. any tips? ...

alphanumeric with at least 1 character

Ok so I finally figured out that I need the following: So the regular expression has to perform: alphanumeric at least 1 letter must have between 4 and 8 characters (either a letter/digit). i.e. an alphanumeric string, that must have at least 1 letter, and be between 4-8 in length. (so it can't be just all numbers or just all letter...

Can you rely on the order that regular expression syntax is interpreted?

(The background for this question is that I thought it would be fun to write something that parses wiki creole markup. Anyway the problem that I think I have a solution to is differentiating between // in a url and as opening/closing syntax for italic text) My question is slightly compound so I've tried to break it up under the headings...

How can I parse CSV data with internal commas in data using Perl?

The data I need to parse looks like: [fild1, filed2, .... filedn] , [filed1, filed2, .... filedn] ..... I call it a special form of CSV data because there are two kinds of comma: those commas outside the [] pair are served as the separator between different records. those commas inside the [] pair are served as the separator betwee...

Ruby 1.9: Regular Expressions with unknown input encoding

Is there an accepted way to deal with regular expressions in Ruby 1.9 for which the encoding of the input is unknown? Let's say my input happens to be UTF-16 encoded: x = "foo<p>bar</p>baz" y = x.encode('UTF-16LE') re = /<p>(.*)<\/p>/ x.match(re) => #<MatchData "<p>bar</p>" 1:"bar"> y.match(re) Encoding::CompatibilityError: incompa...

Equivalent of URL parsing PCRE regex for .NET

There's a PCRE regex for extracting URLs posted here: http://daringfireball.net/2009/11/liberal_regex_for_matching_urls \b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))) What would need to be changed to make it compatible with regex in .NET? ...

Convert all first letter to upper case, rest lower for each word

I have a string of text (about 5-6 words mostly) that I need to convert. Currently the text looks like: THIS IS MY TEXT RIGHT NOW I want to convert it to: This Is My Text Right Now I can loop through my collection of strings, but not sure how to go about performing this text modification. ...

vbscript Classic ASP Regular Expression VBScript runtime (0x800A01A8)

Okay, this is the problem: I am getting this error message when I am trying to run the following script Dim rg Dim match Set rg = New RegExp rg.Pattern = "Mod Read Access" rg.Global = True roles = Session("Roles") Set match = rg.Test(roles) it chokes at the rg.Test(roles) point. I suspect that I may be doing something wrong sinc...