Hi, I have an interesting regex puzzle I hope you might be able to help me with.
What I want to do is assign a 'score' to various strings, based on their prefix. So if a file starts with 'UKL' or 'USL', it receives a score of 10; if it starts with 'EUK' or 'EUS' it receives a score of 9, if...
It worked for me up to a point in the file, then stopped working - couldn't see anything in the file that would break it. I've got around it now by changing the s/// to a m// and removing the tag with with substr:
foreach $line (@lines) {
$line =~ s|^\s+||;
print RPT "$line\n";
$bold = 0...
Makes no difference, I'm afraid. I thought the non-greedy quantifier was only when using wild-card characters like . ? By restricting the regex to search for everything that isn't a closing angle bracket, I'm doing away with the need for the question mark.
I have a rough HTML file (from Word 98) that I'm trying to convert into XML. I've split it into lines on </P> tags, then I'm taking each line in turn, stripping off the tags at the start, then setting a variable $italic if a <I> or </I> tag is found, so:
foreach $line (@lines) {
$line =~...
Hi, I've been searching CPAN for a while now, but I can't find an easy way to convert a Unicode entity (eg л) to UTF-8. Any advice will be very gratefully received. Thanks!
Can't go into too much detail, but they're HTML tables that have been created manually for an application that runs under Mozilla. I didn't spec for id's when they were created, but now we need the id's in there. I just need a quick & dirty way of doing it, I don't really have the time to get...
Hi, I'm trying to add an id number to each cell in a bunch of HTML tables, so I'm using the code:
while ($tabdat =~ s/<td /<td id="$idnum" /g) {
$idnum++;
}
This just hangs in a loop, so how do I do this? Apologies if this is really simple, it's Friday afternoon and I've had quite a day...
Thanks - I thought of that, but the list is going to be very long - it's the contents of a dictionary, basically. This seems very inefficient to me, surely there's a better way?
Hi, I can't find a function that will return the position of a string within an array. For example, if the array is:
[aardvark, abacus, abandon, abate, abattoir...]
I want to search it for 'abate' and return position 3. What I want to do is search an alphabetically-sorted list and see which...
Won't that fail if the file has non-word characters (eg numbers or percent signs)? I would say:
$url =~ m|/([^/]*)$|;
#ie all the non-slash characters after the last slash up to the end of the string
$filename = $1;
Dom
Is everything except 'some link', 'link name' and 'stuff' always going to be part of the string to replace? And is the ' or <a' alternative link always part of it? If so, I think the following:
s/<a href="([^"]*)"[^>]*>[^<]*<\/a> or <a href="([^"]*)"[^>]*>[^<]*<\/a><\/p><h2><br>/$1, $2/
should...
to clarify, if I run the code on the following strings, one after another:
<tag>a tag</tag><tag>another tag</tag>
<tag>yet another tag</tag>
I get:
<tag id="1">a tag</tag><tag id="1">another tag</tag>
<tag id="2">yet another tag</tag>
ie it seems the substitution happens for all matches in...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.