regex

fields from URL

I'm dealing with a scrupt that for some reason can't read normal $_GET and $_POST and just reads the whole thing as a string. This is the string it reads and I'm given this as output. ?field1=value1&field2=value2&field3=value3 I'm writing a function that works with this output to break it up into its individual field1, field2, field3 ...

Regular expression for matching incomplete tags in the form $tagname$

I have a small templating system in javascrip, where the user can put tags in the form $tagname$. I can match all tags with the patter: /\$\w+\$/. Also, I want to match incomplete tags specifically (it would start with $ and finish with a word boundary that is not $). I can't use /\$\w+\b/ because $ is also a word boundary (so it will a...

C# Regex need pattern for string match

This is my second attempt to get this answer since I messed it up first time :s As you can guess Im new to regex basically, the string contains lots of words seperated by "\"'s. so for example \gyifgy8i\gyigyi9g\player_0\k1ng*tar%\gp86gg78.\g79g\player_1\th3dadY>\gyigyigiy\huiohgiu\player_2\j0k$r\g68g6o9g\987pgh890\player_3\PLAYERNAME ...

How to verify a Hyperlink exists on a webpage?

I have a need to verify a specific hyperlink exists on a given web page. I know how to download the source HTML. What I need help with is figuring out if a "target" url exists as a hyperlink in the "source" web page. Here is a little console program to demonstrate the problem: public static void Main() { var sourceUrl = "http://dev...

Java: how to parse double from regex

I have a string that looks like "A=1.23;B=2.345;C=3.567" I am only interested in "C=3.567" what i have so far is: Matcher m = Pattern.compile("C=\\d+.\\d+").matcher("A=1.23;B=2.345;C=3.567"); while(m.find()){ double d = Double.parseDouble(m.group()); System.out.println(d); } the problem is it shows the...

Maximum Regular Expression size in "modern" web browsers?

What's the maximum size of a regular expression in modern browsers (i.e. Firefox 3+, Safari 4+, IE 7+)? Assume a simple regular expression, of, say "foo|bar|baz|woot|..." ...

Reverse case of all alphabetic characters in C# string

What is the simplest way to reverse the case of all alphabetic characters in a C# string? For example "aBc1$;" should become "AbC1$;" I could easily write a method that does this, but I am hoping there is a library call that I don't know about that would make this easier. I would also like to avoid having a list of all known alphabetic c...

RegEx in VBA: Break a complex string into multiple tokens?

EDIT: Two additional token types added. Hi, I am trying to parse a line in a mmCIF Protein file into separate tokens using Excel 2000/2003. Worst case it COULD look something like this: token1 token2 "token's 1a',1b'" 'token4"5"' 12 23.2 ? . 'token' tok'en to"ken Which should become the following tokens: token1 token2 token's 1a',1b'...

My regex is causing a stack overflow in Java; what am I missing?

I am attempting to use a regular expression with Scanner to match a string from a file. The regex works with all of the contents of the file except for this line: DNA="ITTTAITATIATYAAAYIYI[....]ITYTYITTIYAIAIYIT" in the actual file, the ellipsis represents several thousand more characters. When the loop that reads the file arrives on...

Split string of varying length using regex

I don't know if this is possible using regex. I'm just asking in case someone knows the answer. I have a string ="hellohowareyou??". I need to split it like this [h, el, loh, owar, eyou?, ?]. The splitting is done such that the first string will have length 1, second length 2 and so on. The last string will have the remaining charact...

RegEx - problem with multiline input

I have a String with multiline content and want to select a multiline region, preferably using a regular expression (just because I'm trying to understand Java RegEx at the moment). Consider the input like: Line 1 abc START def Line 2 Line 3 gh END jklm Line 4 Assuming START and END are unique and the start/end markers for the region...

Help with regular expression to scrape website.

I need to write a regular expression for the following (NB. ignore carriage returns, I've added them for readability): <strong>Contact details</strong> <p><label>Office:</label>&nbsp;+44 (0)12 3456 7890<br /> <label>Direct:</label>&nbsp;+44 (0)12 3456 7890<br /> <label>Mobile:</label>&nbsp;+44 (0)1234 567890<br /> <label>E-mail:</label>...

DOMDocument XPath

Can somebody show me some examples to import a html-page and use the XPath to find the keywords including the rest of the text from the div, p, title etc. Thank you! EDIT: In this case i use my webcrawler for example, i have a form to get the website to be crawled and the keywords wich has to be find in pages of the website. http://c...

Java Regex for genome puzzle

I was assigned a problem to find genes when given a string of the letters A,C,G, or T all in a row, like ATGCTCTCTTGATTTTTTTATGTGTAGCCATGCACACACACACATAAGA. A gene is started with ATG, and ends with either TAA, TAG, or TGA (the gene excludes both endpoints). The gene consists of triplets of letters, so its length is a multiple of three, a...

How do I extract words in braces using regular expressions?

I want to extract all words enclosed in curly braces, so I have an expressions like this foo {bar} moo {mar} The string to match may have any number of these words, but I'm starting to think I'm approaching this problem in the wrong way. My attempt And I've tried to extract the words braces into groups so I can use every single matc...

Regex to get float from a string

Hay, i have a system basically tracks finances. In this application it has a "cost" field (which unfortunately is VARCHAR field). This field has various values entered like: £90 £210 per day £50 per logo Design - £180 £36 p/h £1009.51 Is there any way i can convert these to floats? I tried just using (float) to juggle the type into a ...

PHP - check a variable using regex

Hi. Im about to create a registration form for my website. I need to check the variable, and accept it only if contains letter, number, _ or -. How can do it with regex? I used to work with them with preg_replace(), but i think this is not the case. Also, i know that the "ereg" function is dead. Any solutions? ...

RegEx to Remove Unwanted text

I'm still kind of new to RegEx in general. I'm trying to retrieve the names from a field so I can split them for further use (using Pentaho Data Integration/Kettle for the data extraction). Here's an example of the string I'm given: CN=Name One/OU=Site/O=Domain;CN=Name Two/OU=Site/O=Domain;CN=Name Three/OU=Site/O=Domain I would like...

Removing set of tags from within another set, using regular expressions

Hello, I've got a big XML file I'm editing with BBEdit. Within the XML file, which is a digital recreation of an old diary, is text that is enclosed in note tags. <note>Example of a note.</note> Some note tags, however, have quotations enclosed in quote tags nested in them. <note>Example of a note, but <quote>"here is a quotation w...

Simplifying Regex's - escaping

I want to enable my users to specify the allowed characters in a given string. So... Regex's are great but too tough for my users. my plan is to enable users to specify a list of allowed characters - for example a-z|A-Z|0-9|, i can transform this into a regex which does the matching as such: [a-zA-Z0-9,]* However i'm a little l...