regex

Regex line by line: How to match triple quotes but not double quotes

I need to check to see if a string of many words / letters / etc, contains only 1 set of triple double-quotes (i.e. """), but can also contain single double-quotes (") and double double-quotes (""), using a regex. Haven't had much success thus far. ...

how to remove a character with jquery

I have this: <span class="name"><span class="gost">Yahoo</span>, </span> I tried something like this, but no luck: $("span.name").html( $(this).replace(/,/g, '') ); ...

Regular Expression for Conditional Substitution of Angle Brackets

Is it possible to create a single regexp to replace < and > with their entity equivalents? s/<|>/&lt;|&gt;/ ...

Match a string between two same chars

Hi all, I am trying to use back references in Java regex, but it seems I'm not doing it the right way and can't get it work. I wanted to be able to match parts of string surrounded by 2 same quotes, say find if a string contains "whatever" or 'whatever'. I then wrote the following code : Pattern p = Pattern.compile("(\"|\')whatever\1"...

Replacing &nbsp; from javascript dom text node

I am processing xhtml using javascript. I am getting the text content for a div node by concatenating the nodeValue of all child nodes where nodeType == Node.TEXT_NODE. The resulting string sometimes contains a non-breaking space entity. How do I replace this with a regular space character? My div looks like this... <div><b>Expires...

How can I use a regular expression to validate a password?

How can I use a regular expression to validate the characters in a password? The password must contain at least 1 special character, 1 digit and 1 letter. It should [not] be more than 8 characters long. ...

How can I detect which line I'm processing in Perl?

Got a text file that looks like: 200.0 250.0 300.0 350.0 400.0 162:02:10 017:01:56 017:08:18 011:16:22 008:40:18 580.0 600.0 620.0 640.0 660.0 004:04:01 001:47:27 007:25:29 017:44:53 003:07:34 Trying to parse out lines 1 & 3 as "values", and lines 2 & 4 as "times". My code: if($line =~ /^...

Regex to get the link in href. [asp.net]

hi i got problems to get my regex to work. im working with C# asp.net i will post the code i use now and what i cant get to work is the second regex to get whatever is in the href="LINK" thx in advance var textBody = "lorem ipsum... <a href='http://www.link.com'&gt;link&lt;/a&gt;"; var urlTagPattern = new Regex(@"<a.*?href=["...

301 Redirect - matching a portion of the filename

[UPDATE] What I ask below just isn't possible. In which case, as my brain hurts, how can I simply redirect mydomain/folderA/folderB/name-0000.php to myNewDomain/folderC/folderB/name.php [/UPDATE] I currently have some URL's which follow the pattern below. /folder/folder2/name-name-id.php The content has now been moved to a new do...

php regex for link url

Hay guys i need help on a regex. I'm using file_get_contents() to get the source of a page, i want to then loop through the source and find all the and extract all the HREF values into an array. Thanks ...

Exclude specific subdirectory from mod_rewrite rule

I currently have: RewriteRule ^scripts/(.*\.js) /combine.php?type=javascript&files=$1 Current scripts folder looks like: scripts/ folder1 f1.css folder2 f2.css folder3 f3.css bespoke bespoke.css css.ss I would like this rule to exclude anything within the scripts/bespoke/ folder. ...

How can I get the regular expression correct?

How can I write just one expression to represent the following cases? These Matrix Blocks all have similar structures, with the eception of different lines inside, varying all the way. Matrix "mat-31" SPRING 3 1 { 0.000000 43.039398 0.000001 -0.000000 } Matrix "mat-48" SPRING 3 2 { 0.000000 1.000000 1.000000 1.000000 3.4957...

Remove control characters from php String

Hi all, seems trivial but give me a hard time: Does anyone have a hint for me on how to remove control characters like STX from a php string. I played around with preg_replace("/[^a-zA-Z0-9 .\-_;!:?äÄöÖüÜß<>='\"]/","",$pString) but found that it removed way to much. Is there a way to remove only controll chars? tia K ...

What class of language can Perl regular expressions be used against?

I know that some of the capabilities of the Perl regular expression engine are not regular. However, what class is it? It might be context-free, but CS theory was never my strongest subject. ...

Figure out method name from line number in Java?

Given a line number, the code file, as well as the compiled class file if necessary, what is the most elegant way to get the signature of the surrounding method (if the line number is even in a method)? Things to keep in mind: the line might not even be in a method the line might be in a method of an inner or anonymous class While...

scrape & regex match doesn't work

Ok, I have page with something like this (I added 'scrapehere' string to make it easier to navigate, this page isn't 100% correct html and it has two identical fields with different values. No, I can't fix it because it's cms i'm using and i feel it would be too complicated for me to do): scrapehere<input type="hidden" id="_someid" name...

how to escape < sign in php regex

Should i add some character/s before or after < character (which is in string i'm trying to extract something from - it's html page) when doing preg match? ...

Reading Website pages

Hi, my question is as follows: assume there is a website called website.com/a the website is being developed using PHP, Perl, Ruby and other languages. i want to be able from my website to read this website pages, execute the code and then analyse the HTML result page tags and getting the content using PHP. it's like reading news f...

Visual Studio RegEx Replace - 2 or more?

Using visual studio search and replace, is there a way to search for two or more instances of something? Visual Studio regex does not seem to support the "{}" syntax for indicating quantity. E.G: Match Text: 11 OR 111 OR 1111 Standard Regex: [1]{2,} ...

Remove HTML Tags in Javascript with Regex

I am trying to remove all the html tags out of a string in Javascript. Heres what I have... I can't figure out why its not working....any know what I am doing wrong? <script type="text/javascript"> var regex = "/<(.|\n)*?>/"; var body = "<p>test</p>"; var result = body.replace(regex, ""); alert(result); </script> Thanks a lot! ...