Hello,
Let’s take this string has an example:
D:/firstdir/Another One/and 2/bla bla bla/media/reports/Darth_Vader_Report.pdf
I want to cut the first part of the path:
D:/firstdir/Another One/and 2/bla bla bla
And replace it with **../**, and keep the second part of the path
(media/reports/Darth_Vader_Report.pdf)
If I knew the leng...
I need to add href=" before an http:// if this http:// doesn't follow href=" or src="
Following code partly works. Partly means it considers <a href=" only but not src="
$str= preg_replace(
"/(?<!a href=\")((http|ftp)+(s)?:\/\/[^<>\s]+)/i",
"<a href=\"\\0\"> target=\"blank\">\\0</a>",
$str
);
Thank you guys in advance ...
I have a python console application that contains 300+ regular expressions. The set of regular expressions is fixed for each release. When users run the app, the entire set of regular expressions will be applied anywhere from once (a very short job) to thousands of times (a long job).
I would like to speed up the shorter jobs by compi...
Suppose I have a pattern in the form of "((?<happy>foo)|(?<sad>bar)|...)" . There could be many more conditions. If I wanted to know which grouping I had found (e.g. searching 12bar34 will return "sad", is there a cleaner way to do it than the code I have now?
Regex objRegex = new Regex("((?<happy>foo)|(?<sad>bar))");
Match objMatch =...
I'm working on a Google appengine project and I've encountered a quandary. The following should (if the regex's are normal) redirect everything which does not contain the word "test" to the MainPage class, and the rest to the TestPage class.
application = webapp.WSGIApplication(
[
...
I am using .Net. I want to match last name which has charecters other than a-z, A-Z, space and single quote and len of charecters should not be between 1-40 . The string that has to be matched is a XML look like this <FirstName>SomeName</FirstName><LastName>SomeLastName</LastName><Address1>Addre1</Address1>
I wrote regualr expression b...
hi guys,
I am given a page url like 'http://abc.com/test.php?a=1&b=2&c=3'. Now I have been told to change the value of b to 5 so that it becomes 'http://abc.com/test.php?a=1&b=5&c=3'.
i.e change from http://abc.com/test.php?a=1&b=2&c=3 to http://abc.com/test.php?a=1&b=5&c=3
Note: variable b here can ref...
How can I look for an instance for certain file extensions, like .(jpg|png|css|js|php), and if there is NOT a match send it to index.php?route=$1.
I would like to be able to allow period's for custom usernames.
So, rewrite http://example.com/my.name to index.php?route=my.name
Current setup:
.htaccess:
<IfModule mod_rewrite.c>
Rewrit...
I was looking for a way to replace instances of
[number][char] or [char][number] like it occurs in mathematical expressions (e.g. 4x + 20y)
with [number]*[char] or [char]*[number],
I have two problems with that
How do i reuse the found number and char => `replaceAll("[0-9999][a-z]", "[1]*[2]")` ?
Whats the best way to represent a num...
Have a regex:
.*?
(rule1|rule2)
(?:(rule1|rule2)|[^}])*
(It's designed to parse CSS files, and the 'rules' are generated by JS.)
When I try this in IE, all works as it should.
Ditto when I try it in RegexBuddy or The Regex Coach.
But when I try it in Firefox or Chrome, the results are missing values.
Can anyone please explain what t...
Im trying to search for something on a page but i keep getting this silly error
this is the error i am getting
Warning: preg_match() [function.preg-match]: Unknown modifier 'd'
this is the code im using
$qa = file_get_contents($_GET['url']);
preg_match('/<a href="/download.php\?g=(?P<number>.+)">Click here</a>/',$qa,$result);
And $...
I'm trying to match all occurances of "string" in something like the following sequence except those inside @@
as87dio u8u u7o @string@ ou os8 string os u
i.e. the second occurrence should be matched but not the first
Can anyone give me a solution?
...
What is the best method for splitting or extracting the css properties out of as string and into an object?
var cssProperties = 'background:green;content:"Content;";color:pink;';
The above should result in the following
var theObject = {
background:'green',
content:'"Content;"',
color:'pink'
}
Unfortunately I can not ju...
I want to check for special characters in a string EXCEPT spaces and delete them.
Ex: input = "Oh Boy!!#$" output = "Oh Boy"
Can someone help me with the regular expression to implement this in C#
...
This is a design question.
Background: We get a web request into our system from many different websites (for a widget that we give out), from which we grab the referrer string (if it exists). We use the referrer to decide on some things within the application. The problem arises in that I need to look at a list of "sites" (urls, partia...
I have a program with a function that retrieves a relatively short text string from one SQL database table ("html"), runs a number of regular expression queries on it, and then stores the output in another database table ("profiles"). "Html" has about 8 million records and "profiles" stores only the results. It is currently very slow -...
Need to search a string and replace value="ANYTHING" with value="", basically blank out the value. Thanks.
...
I have a textbox with a RegularExpressionValidator. I want to require the user to enter at least n characters. I'd also like to remove whitespace both at the start and end of the textbox. I'd still like to allow spaces within the textbox, I just want to remove the excess at the beginning and end.
I basically don't know how to combine...
(\d+(?:\.\d+)?)\D*$ - this regex extracts price from any string with decimal point, but I want to extract decimal point only when there is something but not zero like when there is 300.50 or 300.25 then decimal point should be extracted but if there is 300.00 then the decimal point should not be extracted, what to do ?
This is ok, or an...
Nearing what I would like to think is completion on a tool I've been working on. What I've got going on is some code that does essentially this:
open several files and urls which consist of known malware/phishing related websites/domains and create a list for each, Parse the html of a url passed when the method is called, pulling out a...