regex

Matching part of website with a regexp.

With a cURL request I load a complete website into a variable: $buffer. In the source of the site there are two labels in between which my relevant content is placed. ****** bunch of code ******* <!-- InstanceBeginEditable name="Kopij" --> this part I want to store in a match <!-- InstanceEndEditable --> ****** bunch of code **...

Slug ID's with the same name?

I want to create slug URL's from a users title in my system. If a user types "The best way's to get slim; period!", then I want the slug to be "the-best-ways-to-get-slim-period". Also, if someone has already created a page with that title I want the slug to be "the-best-ways-to-get-slim-period-1". My question is how can I check the da...

Using PHP how can i apply HTMLentities() to a backreference in a preg_replace() call?

At the minute i have: $Text = preg_replace("/\[code\](.*?)\[\/code\]/s", "<mytag>\\1</mytag>", $Text); how can i escape the backreference using htmlentities()? ...

Java Split not working as expected

I am trying to use a simple split to break up the following string: 00-00000 My expression is: ^([0-9][0-9])(-)([0-9])([0-9])([0-9])([0-9])([0-9]) And my usage is: String s = "00-00000"; String pattern = "^([0-9][0-9])(-)([0-9])([0-9])([0-9])([0-9])([0-9])"; String[] parts = s.split(pattern); If I play around with the Pattern and ...

regex problem with url

i need to find regex that suitable with this.. [url]%252FShowOneUserReview-g298570-d301416- r63722677%26sl%3Dzh%26tl%3Den_US%26hl%3Den_US%26ie%3DUTF-8 its situated in <a href/redirect.. and combine with other url such as url=http://translate.google.com/translate[url] is it possible for me to find only [url]...-8? ...

Extract title tags from normal text

I am working on one task, to extract title tag from given normal text ( it's not a HTML DOM ). I have below cases where need to extract title tag(s) : Case 1 : <html> <head> <title>Title of the document</title> </head> <body> The content of the document...... </body> </html> Expected : Title of the document Case 2 : <htm...

Regular expression, How to allow combination of dot (period) and letters ?

Hi , I want to allow (.) and (a-zA-Z) letters and _ and - , I have some problems with the (.) , Any idea ? Thanks in advance , Ish ...

Regular Expression - Want two matches get only one

I'm working wih a regular expression and have some lines in javascript. My expression should deliver two matches but recognizes only one and I don't know whats the problem. The Lines in javascript look like this: if(mode==1) var adresse = "?APPNAME=CampusNet&amp;PRGNAME=ACTION&amp;ARGUMENTS=-A7uh6sBXerQwOCd8VxEMp6x0STE.YaNZDsBnBOto8YWs...

Javascript replacing HTML char code with actual character

I have a HTML input text, and its values are populated from a related div. My problem is that the div contains characters like &amp; which will display correcly as '&' sign in div but when copied to text box the text '&amp;' will be dispalyed How can i convert &amp; to & and '&lt;' to '<', '&nbsp;' to ' ' ??? ...

Remove non-alphanumerical characters excluding space

I have this statement: String cap = Regex.Replace(winCaption, @"[^\w\.@-]", ""); that transforms "Hello | World!?" to "HelloWorld". But I want to preserve space character, for example: "Hello | World!?" to "Hello  World". How can I do this? ...

Match regex from right to left?

Hi! Is there any way of matching a regex from right to left? What Im looking for is a regex that gets MODULE WAS INSERTED EVENT LOST SIGNAL ON E1/T1 LINK OFF CRC ERROR EVENT CLK IS DIFF FROM MASTER CLK SRC OF from this input CLI MUX trap received: (022) CL-B MCL-2ETH MODULE W...

How to make string from regex and value of group

I have regexp for twitter profile url and someone's twitter profile url. I can easily extract username from url. >>> twitter_re = re.compile('twitter.com/(?P<username>\w+)/') >>> twitter_url = 'twitter.com/dir01/' >>> username = twitter_re.search(twitter_url).groups()[0] >>> _ 'dir01' But if I have regexp and username, how do I get ur...

Removing unnecessary parentheses in a regular expression

Suppose I have (in a javascript regular expression) ((((A)B)C)D) Of course that really reads ABCD Is there an algorithm to eliminate unnecessary parentheses in a string like that? ...

How to include named capture groups in java regex?

I'm new to regex in Java and I can't figure out how to include named capture groups in an expression. I'm writing a ScrewTurn Image Converter for Confluence's Universal Wiki Converter. This is what I have: String image = "\\[image(?<align>auto)?\\|\\|{UP\\(((?<namespace>\\w+)\\.)?(?<pagename>[\\w-]+)\\)}(?<filename>[\\w- ]+\\.[\\w]+)\\]...

How to test a regex password in Python?

Using a regex in Python, how can I verify that a user's password is: At least 8 characters Must be restricted to, though does not specifically require any of: uppercase letters: A-Z lowercase letters: a-z numbers: 0-9 any of the special characters: @#$%^&+= Note, all the letter/number/special chars are optional. I only want to ver...

Regex - match all .cs files, but not designer generated files?

I've got a regex pattern which I am using to match files having particular extensions. However I do NOT want it to match any .Designer.cs files; how would I implement such into my pattern? \.(bat|cs|java|html|etc)$ ...

Regular Expression: Any character that is NOT a letter or number

I'm trying to figure out the regular expression that will match any character that is not a letter or a number. So characters such as (,,@,£,() etc ... Once found I want to replace it with a blank space. Any advice. ...

extract word with regular expression

I have a string 1/temperatoA,2/CelcieusB!23/33/44,55/66/77 and I would like to extract the words temperatoA and CelcieusB. I have this regular expression (\d+/(\w+),?)*! but I only get the match 1/temperatoA,2/CelcieusB! Why? ...

automatic formatting in web page content

i have content stored as raw text in a database that i show in a HTML table on a web site. In the content people refer to numbers and i want to have those numbers automatically become links For example, in a field i might have This description is for driving a car. The manual refers to ABC:25920 and is very durable. In this case ab...

regexp target last main li in list

I need to target the starting tag of the last top level LI in a list that may or may-not contain sublists in various positions - without using CSS or Javascript. Is there a simple/elegant regexp that can help with this? I'm no guru w/ them, but it appears the need for greedy/non-greedy selectors when I'm selecting all the middle text...