Is it possible to use regex to only replace X number of occurrences of a particular string?
For example, if I have the word 'lion' in a string 10 times, could I use regex to only replace the first 6 occurences instead of all of them?
...
Hi, I have some content that I am trying to parse...
I have html and with in the html I want to replace all my img tags with a custom string. Now one of the problems I have is that some content that comes in: the image tags is between a anchor.
ex.
<a href="link"><img></a>
The following code I have works...but I want it to be option...
I am working on a small DSL that uses the nomethod fallback for overloading to capture the operators used on the overloaded values. This is similar to the function of the symbolic calculator described in overload's documentation.
This works fine for the standard comparison operators, but consider the following:
my $ret = $overloaded =...
$string = '<ul>
<li id="34334" class="some_class"><a href="/stack/">Text</a></li>
<li id="someid" class="more_class"><a href="/overflow/">Text</a></li>
</ul>';
What I need (actually don't know how to do, please help):
We must check <a> inside each <li>
If href of <a> == /stack/, then add extra class current for parent <li>
...
Hi,
for the last hour I have been trying to figure this out myself but I am just not having any success and thought maybe you could help.
Basically I am having a html email document that has a lot style attributes for inline styling of elements that look somewhat like
<th rowspan="10" style="font-weight: normal; vertical-align: top; te...
I have a regex that looks like this
/^(?:\w+\s)*(\w+)$*/
What is the ?:?
...
I have a list of strings in my richtextbox. I need a code to check if there are numbers in the first line, if there is then proceed with the rest of my code, else delete first line.
...
I have a php file that can read the contents of other files perfectly and return them as a string.
$contents = $file->read(); // return as string.
i need to be able to search and replace certain lines
lines that begin with $this->Session->setFlash and end with , true)); must be replaced with
lines that begin with
$this->Session->s...
I have a python script that reads from a config file. The config file is going to contain some user defined regex patterns. However, I was thinking I'd like to let the user use either full regex patterns, OR shell wildcards. So I should be able to interpret both
*.txt
as well as
.*\.txt$
correctly. So those 2 should be equivalent.
How...
url1 = http://xyz.com/abc
url2 = http://xyz.com//abc
I want to write a regex that validate both url1 and url2
...
Hi I need write a regular expression for RegularExpressionValidator ASP.NET Web Controls.
The regular expression should ALLOW all alphabetic characters but not number and special characters (example: |!"£$%&/().
Any idea how to do it?
thanks
...
Hi,
Will a regex created with the following terms match the same results?
"canon| eos" "1d"
and
canon|eos 1d
Now I do not want to match the quotation marks (") in the string. Will the fact they are in there make a difference.
Will the first term match "canon but not canon?
Am I right in what I am saying?
...
I'm currently playing with the Stack Overflow data dumps and am trying to construct (what I imagine is) a simple regular expression to extract tag names from inside of < and > characters. So, for each question, I have a list of one or more tags like <tagone><tag-two>...<tag-n> and am trying to extract just a list of tag names. Here are...
I would like a command line function that I can run on any file to change the include("myinc.inc"); PHP statement to include 'myfile.inc'; I have made a start by adding the following to my ~/.bashrc file:
function makestandard() {
perl -p -i -e 's/include\("([\w\.]+)"\)/include '$1'/g' $*
}
I source ~/.bashrc; and run the command ...
I just started using Boost::xpressive and find it an excellent library... I went through the documentation and tried to use the ! operator (zero or one) but it doesn't compile (VS2008).
I want to match a sip address which may or may not start with "sip:"
#include <iostream>
#include <boost/xpressive/xpressive.hpp>
using namespace boos...
Hello guys,
I have the option to use a regex to validate some values and I would like to know the best way to do it.
I have several ranges (not in the same regex/validation) such as 1-9 (this is easy :P), and:
1-99
1-999
1-9999
Also, I need to check for leading zeros, so, 0432 is a possible match.
Any ideas?
I know that Regex might...
Content is
Hello World.
<a href="#" target=_blank>hello World</a>
How to replace the in html code and keep the other in the text.
...
I want to have a range between 0 to 65536 , what would be the regular expression for that?
...
Hey there,
I'm having trouble building the correct regex for my string. What I want to do is get all entities from my string; they start and end with '. The entities are identifiable by an amount of numbers and a # in front. However, entities (in this case a phone number starting with #) that don't start or end with ' should not be matc...
Hi !
I have a XAML document and I want to select all texts with Regex with this form:
Default=xyz}
I wrote for it this very simple regex and it works:
Default=.+}
Now, how do I exactly the opposite? I want to delete all other text than this in the document.
I'm using Notepad++.
Thanks
...