regex

Auto incrementing unique url

I am looking to create an auto incrementing unique string using PHP, containing [a-Z 0-9] starting at 2 chars long and growing when needed. This is for a url shrinker so each string (or alias) will be saved in the database attached to a url. Any insight would be greatly appreciated! ...

RegEx - Not match inside a text?

I am working with iCal entries: BEGIN:VEVENT UID:944f660b-01f8-4e09-95a9-f04a352537d2 ORGANIZER;CN=****** DTSTART;TZID="America/Chicago":20100802T080000 DTEND;TZID="America/Chicago":20100822T170000 STATUS:CONFIRMED CLASS:PRIVATE X-MICROSOFT-CDO-INTENDEDSTATUS:BUSY TRANSP:OPAQUE X-MICROSOFT-DISALLOW-COUNTER:TRUE DTSTAMP:20100802T212130Z ...

Regular Expression , URL validity problem

Example link http://stackoverflow.com/questions/tags/ruby true url http://stackoverflow.com/questions/@#dsd/javascript false url How i check the validity of only /tags/ part not whole url IS any one who helps me Is anyone give me regular expression for this url part. How i validate my url as per my condition Thanks ...

Finding the last group in a regular expression

Hello everyone, Three underscore separated elements make my strings : - first (letters and digits) - middle (letters, digits and underscore) - last (letters and digits) The last element is optional. Note : I need to access my groups by their names, not their indices. Examples : String : abc_def first : abc middle : def last : None ...

Extracting a Hostname's TLD with a Regular Expression

Extracting an accurate representation of the top-level domain of a hostname is complicated by the fact that each top-level domain registry is free to make up its own policies regarding how domains are issued and what subdomains are defined. As there doesn't appear to be any standards body coordinating these or establishing standards, thi...

Searching Binary Data in Ruby

Using only pure ruby (or justifiably commonplace gems) is there an efficient way to search a large binary document for a specific string of bytes? Deeper context: the mpeg4 container format is a 4-byte indexed serialised data structure, without having to parse the structure fully (I can assume it is valid) I want to pull out specific ...

Create a case-insensitive regular expression from a string in Ruby

Let's say that I have an arbitrary string like `A man + a plan * a canal : Panama!` and I want to do a regex search for strings that are the same other than case. That is, this regular expression should match the string `a man + A PLAN * a canal : PaNaMa!` I take it the best approach is to backslash-escape every character with a sp...

python regexp help

Good day. Little question about reg exp. I have a string look like http://servercom/smth/Age=&Filter=2& How can i cut & with regexp from url? After regexp url-string must be http://server.com/smth/Age=1&Filter=2& ...

Levenshtein Distance on only part of a string (Java)

I have an online web application with a top menu tree for opening different widgets for performing different tasks. As the app grows more powerful, that tree has become large and difficult to navigate. I've implemented a search feature, where users can just type the menu name or part of it and I use regex to find all items in the menu ...

Intelli-J structural search regex questions...

I need to match variables that start with a lowercase letter and don't end in an underscore. I have these three fields: private String shouldFlag; private String shouldntFlag_; private String SHOULDNTFLAG; With this pattern inverted: ^[a-z].*_$ Used with for fieldname in the following template: class $Class$ { $FieldType$ $Field...

Compiling a regex inside a function that's called multiple times

If you compile a regex inside a function, and that function gets called multiple times, does Python recompile the regex each time, or does Python cache the compiled regex (assuming the regex doesn't change)? For example: def contains_text_of_interest(line): r = re.compile(r"foo\dbar\d") return r.match(line) def parse_file(fn...

Purpose of the \G anchor in regular expressions

I simply don't understand what the \G anchor does. If I execute /\G\d\d/ on 1122aa33, it will match 11 and 22. However, when I try /\d\d\G/ on 1122aa33, it matches nothing. Can someone enlighten me? ...

Validating input for Textbox on C# Winforms

I am attempting to validate that the input into a textbox on a C# winforms conforms to a valid pattern. The pattern must be a string that consists only of the following characters 0 to 9 A to Z "-" "/" I am looking at using the "Validating" event on the textbox to perform the validation but I am struggling with the correct Regular ...

Regex to find commas that aren't inside "( and )"

Hi, I need some help to model this regular expression. I think it'll be easier with an example. I need a regular expression that matches a comma, but only if it's not inside this structure: "( )", like this: ,a,b,c,d,"("x","y",z)",e,f,g, Then the first five and the last four commas should match the expression, the two between xyz and...

pyton regex to find any link that contains the text 'abc123'

I am using beautifuly soup to find all href tags. links = myhtml.findAll('a', href=re.compile('????')) I need to find all links that have 'abc123' in the href text. I need help with the regex , see ??? in my code snippet. ...

help printing out hash keys to needed format

I need help printing out data from a hash/hash ref to STDOUT or file with data in a specific order if possible. I have a perl routine that uses hash references like so: #!/usr/local/bin/perl use strict; use warnings; use File::Basename; use Data::Dumper; my %MyItems; my $ARGV ="/var/logdir/server1.log"; my $mon = 'Aug'; my $day = '0...

Matching until the first forward slash not followed by a forward slash

I have URLs in the following format: STATIC_PATH=http://abc.com/0123/3456 STATIC_PATH=http://xyz.com I want to match until and including the first forward slash not immediately followed by a forward slash. In the first URL that would match be http://abc.com/, in the second URL, it would be http://xyz.com. Can you give me the regex for...

How could I group duplicates from a collection?

I'm creating a program that parses a log file for a user's name and its GUID (Global unique identifier) using regular expressions. So far, my program extracts the data properly, and stores it in a two-column DataTable. Outputting its content with this code: foreach (DataRow dr in guids.Select("","guid")) { Console.WriteLine(...

C# Regex Replace weird behavior with multiple captures and matching at the end of string?

I'm trying to write something that format Brazilian phone numbers, but I want it to do it matching from the end of the string, and not the beginning, so it would turn input strings according to the following pattern: "5135554444" -> "(51) 3555-4444" "35554444" -> "3555-4444" "5554444" -> "555-4444" Since the begining portion is what u...

optimize regex which matches two html tags

((<(\\s*?)(object|OBJECT|EMBED|embed))+(.*?)+((object|OBJECT|EMBED|embed)(\\s*?)>)) I need to get object and embed tags from some html files stored locally on disk. I've come up with the above regex to match the tags in java then use matcher.group(1); to get the entire tag and its contents Can anyone perhaps improve this? Is th...