regex

Help For Regular Expression

Hi, I want to convert a link to a definite text by using regular expression.While binding datagrid,i have a function which convert (look: the text) to link.My Function is here. Private Function Convertlook(ByVal str As String) As String Dim look As String Dim pattern As String = "\(look: ([a-z0-9$&.öışçğü\s]+)\)" ...

What's the most useful or interesting regular expression you've used in a program?

Duplicate of: http://stackoverflow.com/questions/20448/what-is-the-most-brilliant-regex-youve-ever-used I was reading about using a regular expression to solve Sudoku, and so was wondering what other useful or interesting regular expressions people have come up with. ...

Which is more efficient regular expression?

I'm parsing some big log files and have some very simple string matches for example if(m/Some String Pattern/o){ #Do something } It seems simple enough but in fact most of the matches I have could be against the start of the line, but the match would be "longer" for example if(m/^Initial static string that matches Some String Pat...

Regular expressions with matching brackets

I'm trying to extract specific hard coded variables from C source code. My remaining problem is that I'd like to parse array initialisation, for example: #define SOMEVAR { {T_X, {1, 2}}, {T_Y, {3, 4}} } It's enough to parse this example into "{T_X, {1, 2}}" and "{T_Y, {3, 4}}", since it's then possible to recurse to get the full struc...

Regex: How to match the first word after an expression

For example, in this text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eu tellus vel nunc pretium lacinia. Proin sed lorem. Cras sed ipsum. Nunc a libero quis risus sollicitudin imperdiet. I want to match the word after 'ipsum'. ...

Regular Expression to match outer brackets

I need a regular expression to select all the text between two outer brackets. Example: some text(text here(possible text)text(possible text(more text)))end text Result: (text here(possible text)text(possible text(more text))) I've been trying for hours, mind you my regular expression knowledge isn't what I'd like it to be :-) so any ...

Regex to find special characters from a String with some exceptions

I need to write a small regex which should match the occurrences of literal character * when it appears with any other special character. For example, I need to catch all of these occurrences !* )* (* ** *.* . The exception to this is *= and =*, which I want to allow. I tried writing the regex as \W&&[^=]\*|\*\W&&[^=] but this doe...

Regex to find special characters in a String with some exceptions

I had just got a similar (but not exact) question answered. I now need help with this question below. I want to write a regex to match a character if its a non word, non digit and non star (*) character. So, the characters [0-9][a-z][A-Z] * should not match and any others should. I tried writing [\W[^*]] but it doesn't seem it works. ...

Python Regular Expression Substitution

I have a block of text, and for every regex match, I want to substitute that match with the return value from another function. The argument to this function is of course the matched text. I have been having trouble trying to come up with a one pass solution to this problem. It feels like it should be pretty simple. ...

Replacing escape characters in Powershell

I have a string that consists of "some text \\computername.example.com\admin$". How would I do a replace so my final result would be just "computername" My problems appears to not knowing how to escape two backslashes. To keep things simple I would prefer not to use regexp :) EDIT: Actually looks like stackoverflow is having proble...

Regex matching question

Alright, i promised myself i would learn Regex one day.. but today is not that day. What is the correct expression for matching #_ (where _ is any character EXCEPT {)? Clarification: I am working on a syntax highlighting system for Ruby and i am defining the rules for comments. The specification that the '{' not be included is to d...

ASP.NET RegularExpressionValidator, validate on a non-match?

Is there a way to use the RegularExpressionValidator to validate only when the ValidationExpression does not match? In particular use a PO BOX regex to validate an address that is NOT a PO BOX. Thanks! ...

Does the 'o' modifier for Perl regular expressions still provide any benefit?

It used to be considered beneficial to include the 'o' modifier at the end of Perl regular expressions. The current Perl documentation does not even seem to list it, certainly not at the modifiers section of perlre. Does it provide any benefit now? It is still accepted, for reasons of backwards compatibility if nothing else. As not...

Regular Expression Question

Hi All, I'm writing a term paper on regular expressions and I'm a bit confused regarding the way one uses the word "match" when referring to regexes. Which of the following is the correct wording to use: "The regular expression matches the string" or "The string matches the regular expression" Or are they both correct? All opini...

Efficient way of extracting specific numerical attributes from XML

The application I work uses XML for save/restore purposes. Here's an example snippet: <?xml version="1.0" standalone="yes"?> <itemSet> <item handle="2" attribute1="30" attribute2="blah"></item> <item handle="5" attribute1="27" attribute2="blahblah"></item> </itemSet> I want to be able to efficiently pre-process the XML which I read i...

How would I sort files to directories based on filenames?

I have a huge number of files to sort all named in some terrible convention. Here are some examples: (4)_mr__mcloughlin____.txt 12__sir_john_farr____.txt (b)mr__chope____.txt dame_elaine_kellett-bowman____.txt dr__blackburn______.txt These names are supposed to be a different person (speaker) each. Someone in another IT department ...

Get a simliar string a discharge the rest

Hey guys, wonder if you could help me out with some Javascript. I have a string that is log message, and i'm waniting to grab a section out of this log and display that on it's own eg.(bear in mind the log section is not case sesitive and any letter can be any case, also could be placed anywhere withing the string) $LOG: 08880xbpnd $ ...

Wordpress permalinks: only using the post_id from the URL

I'm trying to have SEO friendly URLs for my wordpress blog, while still having the flexibility to change a post's title at will. My permalink structure would be like this: %post_id%/%postname% However, I'd like wordpress to just consider the %post_id% from the URL when looking for the appropriate post (sort of like here on stackov...

Regular Expression to split on spaces unless in quotes

I would like to use the .Net Regex.Split method to split this input string into an array. It must split on whitespace unless it is enclosed in a quote. Input: Here is "my string"    it has "six  matches" Expected output: Here is my string it has six  matches What pattern do I need? Also do I need to specify any RegexOptions? ...

is there a way to combine xpath and regexp to extract parts of a node value?

this is what I want... Assuming I'm trying to get at the value of 'B' <tree> <nodea> <nodeb> A=foo; B=bar; C=goo; </nodeb> </nodea> </tree> the following is magical syntax which would make sense... I'm looking for something comparable that actually works :) string = "./nodea/nodeb/[ REGEX( 'B=(.*?);' ) ]/ $1" Is there anything lik...