regex

Match a java main class with regexp

Hi, I'm writing a plugin for emacs to compile and run a java source file with one keystroke. Now I would like to find out the name of the main class or if there is none. Anyone knows how to match a java main class name with regexp? My first thought, in pseudo code regex is find the first word preceded by "class " and succeeded by "{"....

(Recursive) Regular expression for .htaccess file

I'm trying to modify my web page, which I currently use QueryStrings to display pages, and want to change website URLs to "search engine friendly" ones. I'm a newbie in regular expressions and also in .htaccess file, and I want to change URLs from http://someaddress.bla/index.php?lang=en&rootCategory=$rootCaty&leafCategory=$lea...

XPCOM C++: Does it support RegExps?

I'm developing a XPCOM C++ component that have to use some RegExps functions Does XPCOM C++ have build-in support for RegExps? ...

How to get the language value from $_SERVER['HTTP_ACCEPT_LANGUAGE'] using PHP?

<?php $language=$_SERVER['HTTP_ACCEPT_LANGUAGE']; echo $language; ?> When I use Firefox to test this block of code, I get en-us,en;q=0.7,ja;q=0.3 ; When I use IE to test the block of code, I get zh-cn . Is the value of $_SERVER['HTTP_ACCEPT_LANGUAGE'] a string? How to determine whether the preferred language is Ch...

Require a Regex in C#

I Required a Regex for the below input string: Input data - ANALYSE/xxxxxxxx: In the string xxxxxx is any characters. Need a regex accordingly to figure it out At the end the colon is there but i need to replace entire 'ANALYSE/xxxxxxxx:' with String.empty. I want to replace the above string with String.empty The regex which i used...

Regular expression

Hi all, I am a newbie in Python. I want to write a regular expression for some name checking. My input string can contain a-z, A-Z, 0-9, and ' _ ', but it should start with either a-z or A-Z (not 0-9 and ' _ '). I want to write a regular expression for this. I tried, but nothing was matching perfectly. Once the input string follows th...

Regular expression to match free email accounts

Hi guys, First post here. I'm been trying to right a regular expression that checks if an email form field contains a free email address, with no luck. Essentially i need to check if the email contains, hotmail, yahoo, gmail etc in the email field. Any help much appreciated. Using PHP/Drupal. regards H ...

Regular Expression with foreign languages

I have a function that I have used a bunch of times in various files which has a signature like: Translate("English Message", "Spanish Message", "French Message") and I am wanting to pull out the English, Spanish and French messages and then output them into a csv so that people who actually know these languages can tell me what I SHO...

How to search a particular type of web addresses?

See these url's: http://en.wikipedia.org/wiki/1_(number) http://en.wikipedia.org/wiki/10_(number) http://en.wikipedia.org/wiki/100_(number) http://en.wikipedia.org/wiki/10000_(number) Is there some way to search a list of all the pages of this format on the WWW? ...

using regex to remove comments from source files

So I'm new to python, (i wrote my first bit of code I it today) (I'm relitivly experienced in C, and decent in C++, Java and assember - if abit out of practice) I'm, making a program to automate the writing of some C code, (I'm writing to parse stigns into enumerations with the same name) C's handleing of stings is, well it's not that gr...

Deleting a regular expression match

I have a program that I need to be able to search a file with regex epressions and delete what regex has found. Here is the code I have been working on: #include <boost/regex.hpp> #include <iostream> #include <string> #include <fstream> #include <sstream> #include "time.h" using namespace std; class application{ private: //Variables ...

match two patterns followed one by another

I'm creating a calendar where users can set events and time in single line, for example: "6pm supper" - event with start time only "8:00 - 16:00 work" - event with time period Regex I'm currently using to get times: [\d]{1,2}[.|:]?[\d]{0,2}[\s]?[am|pm|AM|PM]{0,2} It works fine but I can't figure out how to filter out the unwanted o...

C# - Lost in Regex - Matching groups on different machines

Hi Ive thought i knew how to write basic regex. On my x64 pc in VS2008, C#, im writting the following regex: private static readonly Regex TagRegex = new Regex(@"\{QTable\((?<key>(.*?))#(?<query>(.*?))#(?<columns>(.*?))#(?<heading>(.*?))#(?<tbl>(.*?))#(?<headers>(.*?))#(?<row>(.*?))\)\}", RegexOptions.Compiled | RegexOptions.Multiline...

How do you match something surrounded by 'foo' and 'bar' without matching foo and bar?

as opposed to regex:'foo.+bar' ...

Automatic text marking by regular expressions. Newlines problem.

Hello, i'm having some troubles with regular expressions in ruby. I need to categorize some files that have the first line followed by two newlines, like in this example: GIOVIANA Si scrivono miliardi di poesie sulla terra ma in Giove è ben diverso. Neppure una se ne scrive. E certo la scienza dei gioviani è altra cosa. Che cosa sia ...

Regular expression multiline validator

Hi! I believe it is a simple question. :) In my ASP.NET Web Form I have a multiline TextBox which should be validated with RegularExpression Validator. Text box should contain one ore more strings "a" (just 'a' char, nothing else). So far I got these regular expressions for my RegularExpressionValidator object: (?m:(^a$)+) (?m:\A(^a$...

CKEditor "protects" me from inline stylesheets

I'm trying to integrate CKEditor into Wordpress for a client. I'm not too familiar with it, it's the first time I use it. The client wants to use CKEditor on a textarea that gets stored into a custom field and is displayed in the sidebar of a page. I added support for this form of editing by adding meta boxes to the page edit window. I...

In Vim, how do I match on "=" but not on "=="?

I've tried a number of different search patterns: [^=]=[^=] works but only if = is not at the beginning/end and it also matches the sandwiching characters =\@!==\@! seems like it should work because \@! matches nothing but requires a match, but it doesn't (see :help pattern-overview) [^=]\@==[^=]\@= also doesn't but seems like it shoul...

Problem with simple regular expression in PHP

The best way to explain my problem is to just show you. Input String: /04-11-2010/12:45/ Regular Expression to get date and time parts: preg_match('@/(\d\d)-(\d\d)-(\d\d\d\d)/(\d\d):(\d\d)/@', $input, $matches); PHP Matches Array: Array ( [0] => /01-11-2010/12:45/ [1] => 01 [2] => 11 [3] => 2010 [4] => 12 ...

Regex to replace html links to plain-text URLs

I need to replace links in html: <a href="http://example.com"&gt;&lt;/a&gt; To just plain-text url address: http://example.com UPD. Some clarification here, i need this to strip down html tags from text but preserve link locations. It's purely for internal use, so there won't be any crazy edge-case code. Language is python in this ...