I have a list of urls of type http://www.abc.com/pk/ca and http://www.abc.com/pk
Now, I want to find out only those urls that ends with /pk or /pk/ and don't have anything in between .com and /pk
I need to replace all <p> tags with <br /> tags within a string.
The problem is that the <p> tag can have attributes in it , such as <p align="center"> so I want to delete all occurrences of an opening tag of a paragraph, no matter what attributes are in it, and replace them with <br />.
I am using PHP and had no success getting to the right expression with the preg_replace function.
Any help would be appreciated!
Joel
Hi,
I have an array with words like
$arr = arra("go", "walk", ...)
I would like to replace these words with links f they are matched in sentences. But it should be only if they match exactly (for example "walk" should match "Walk" or "walk!" but not also "walking")
And the replacement should be a simple link like: < a href='#walk' walk< /a
Anybody Any idea?
I'd like to quickly hone in on what failed in a build log output that is nearly 5k lines long, using Notepad++ as my editor for the file. Notepad++ has the nice ability to specify regular expressions, so I am wondering if there is a way to not match:
Compile complete -- 0 errors, 0 warnings
but to match, for example:
Compile complete -- 1 errors, 0 warnings
Compile complete -- 100 errors, 0 warnings
where the match would be (1 or more) errors.
If this isn't possible, I will probably just write a quick line-by-line parsing tool instead, but I was hoping someone on StackOverflow could whip out a regular expression in the same amount of time - I'm definitely not proficient enough with regular expressions to be able to write one for my needs in a short amount of time.
Hello all
I'm trying to find all the 6 digit numbers in a string that do not end in 00.
Something like that
/([0-9]{4})([^00])/ //i know this is wrong
so the string
asdfs dfg_123456_adsagu432100jhasj654321
will give me
results=[123456,654321] and not 432100
Thanks
Have a good day
I am reading a file by line and need to extract latitude and longitude from it.
This how lines can looks:
DE 83543 Rott am Inn Bayern BY Oberbayern Landkreis Rosenheim 47.983 12.1278
DE 21147 Hamburg Hamburg HH Kreisfreie Stadt Hamburg 53.55 10
What's for sure is, there are no dots surrounded by digits except for the ones representing the doubles.
Unfortunately there are Values without a dot, so it's probably best to check for numbers from the end of the String.
thanks for your help!
Hello,
I have this kinda template text :
Hello {#Name#},
Thanks for coming blah on {#Date#} and
we love to see you again here with
{#President#}
So I am trying to get {#...#} templates parts and put them into an array.
But my expression didn't work :
\b(?<=\{\#)(.*)(?=\#\})\b
The result became something like this for this sample text :
{#Something#} Hello {#Brand#}
Result :
Something#} Hello {#Brand
How can I apply multiple regexs to a single string?
For instance, a user inputs the following into a text area:
red bird
blue cat
black dog
and I want to replace each carriage return with a comma and each space with an underscore so the final string reads as red_bird,blue_cat,black_dog.
I've tried variations in syntax along the lines of the following so far:
function formatTextArea() {
var textString = document.getElementById('userinput').value;
var formatText = textString.replace(
new RegExp( "\\n", "g" ),",",
new RegExp( "\\s", "g"),"_");
alert(formatText);
}
I have the following expression which will be used as date validation in the HTML5 "pattern" attribute.
?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))-(?:(?:0[1-9]|1[0-2])-(?:19|20)[0-9]{2}
I want it to allow only valid dates, using "-" as a separator.
This means up to 29th in February if it's a leap year, and 30/31 for other months respectively.
Currently, it only allows years starting with 2 (2012) and months up to 12 (December).
But it limits the day to 29 regardless of which month.
Can anybody help me fix it?
i have this code:
<script type="text/javascript">
var str="KD-R35H2UND";
var patt1=/b*.[EE|EJU].*D/i;
document.write(str.match(patt1));
</script>
i want script can read H2UND but it just show 2UND..
Hi everyone. I'd ideally like a vim answer to this:
I want to change
[*, 1, *, *] to [*, 2, *, *]
Here the stars refer to individual characters in the substring, which I would like to keep unchanged. For example
[0, 1, 0, 1] to [0, 2, 0, 1]
[1, 1, 1, 1] to [1, 2, 1, 1]
If people know how to do this in perl or python or whatever, that would be equally good.
Cheers
I am having a find a replace in a bunch of RTF documents, The basic pattern I need is
\{(?:\\\*)?\\field\\fldlock\{\\\*\\fldinst ?MERGEFIELD ?((?:\\.*?)?[\w\[\]]+?)(?:\\.*?)?\}(?:\{\\fldrslt\})?\}
However I then found out there could potentialy be a newline before each slash, so it turned in to this.
\{(?:\s*\\\*)?\s*\\field\s*\\fldlock\s*\{\s*\\\*\s*\\fldinst\s*MERGEFIELD\s*((?:\\.*?)?[\w\[\]]+?(?:\s*\\.*?)?)?\s*\}(?:\s*\{\s*\\fldrslt\s*\})?\s*\}
But then I hit this it fails
fees totaling $\protect {\field\fldlock{\*\fldinst MERGEFIELD ENTEROUTSTANDINGVETERINARYF
EES}}\plain\f0\fs24\prot
Is there way have to have it match a new line anywhere in the search too without adding (?:\r?\n)? everywhere?
EDIT
To clear up confusion on the new lines. I need to keep the newlines in the document, I only want to remove the newlines if they are inside my match, so in the final example I posted it should replace
fees totaling $\protect {\field\fldlock{\*\fldinst MERGEFIELD ENTEROUTSTANDINGVETERINARYF
EES}}\plain\f0\fs24\prot
with
fees totaling $\protect ENTEROUTSTANDINGVETERINARYFEES\plain\f0\fs24\prot
Hey Everyone,
I need to search a bunch of files for anything that contains either "tblPayment" or "tblInvoice"
I also want to match any tables named "tblPaymentMethod", "tblInvoiceItem", "tblInvoicePayment"
Anybody care to help me out with how to write a regular expression for this?
Thanks again!
Is it possible to use a regular expression to get filenames for files matching a given pattern in a directory without having to manually loop through all the files.
This is my code to pre_match when an amount looks like this: $ 99.00 and it works
if (preg_match_all('/[$]\s\d+(\.\d+)?/', $tout, $matches))
{ $tot2 = $matches[0];
$tot2 = preg_replace("/\\\$/", '', $tot2);}
I need to do the same thing for a amount that looks like this (with a comma): $ 99,00
Thank you for your help (changing dot for comma do not help, there is an "escape" thing I do not understand...
Idealy I need to preg_match any number that looks like an amount with dot or commas and with or without dollar sign before or after (I know, it's a lot to ask :) since on the result form I want to scan there are phone and street numbers...
UPDATE (For some reason I cannot comment on replies) : To test properly, I need to preg_replace the comma by a dot (since we are dealings with sums, I don't think calculations can be done on numbers with commas in it).
So to clarify my question, I should say : I need to transform, let's say "$ 200,24" to "200.24". (could be amounts bettween 0.10 to 1000.99) :
$tot2 = preg_replace("/\\\$/", '', $tot2);}
(this code just deals with the $ (it works), I need adaptation to deal also with the change of (,) for (.))
var r = /\d/g;
var a = r.test("1"); // will be true
var b = r.test("1"); // will be false
console.log(a == b); // will be false
Please explain to me why the result of r.test("1") alternates with each call?
I was able to work around the issue I was having by removing the g modifier. However I would still like to understand why this happens.
I found some partial help but cannot seem to fully accomplish what I need. I need to be able to do the following:
I need an regular expression to replace any 1 to 3 character words between two words that are longer than 3 characters with a match any expression:
For example: walk to the beach == walk(.*)beach
If the 1 to 3 character word is not preceded by a word that's longer than 3 characters then I want to translate that 1 to 3 letter word to ' ?'
For example: on the beach == on ?the ?beach
The simpler the rule the better (of course, if there's an alternative more complicated version that's more performant then I'll take that as well as I eventually anticipate heavy usage eventually).
This will be used in a PHP context most likely with preg_replace. Thus, if you can put it in that context then even better!
I have a table that contains some data given below. It uses a tree like structure
i.e.
Department
SubD1, SubD2 .....
PreSubD1, PreSubD1... PreSubD2, PreSubD2...
pk_map_id preferences ImmediateParent Department_Id
-------------------- -------------------- -------------------- --------------------
20 14 5 1
21 15 5 1
22 16 6 1
23 9 4 2
24 4 3 2
25 24 20 2
26 25 20 2
27 23 13 2
I want to group my records on behalf of department then immediate parent then preferences each seperated by ','
i.e.
department Immediate Parent preferences
1 5,6 14,15,16
2 4,3,20,13 9,4,24,25,23
and this table also
Immediate parent preferences
5 14,15
6 16
4 9
3 4
20 24,25
13 13
In actual scenario all these are my ids which are to be replaced by their string fields.
I am using sql server 2k5
End of line anchor $ match even there is extra trailing \n in matched string, so we use \Z instead of $
For example
^\w+$ will match the string abcd\n but ^\w+\Z is not
How about \A and when to use?
I have an HTML document in .txt format containing multiple tables and other texts and I am trying to delete any HTML (anything within "<") if it's inside a table (between and ). For example:
===================
other text
<other HTML>
<table>
<b><u><i>bold underlined italic text</b></u></i>
</table>
other text
<other HTML>
==============
The final output would be as the following. Note that only HTML within and are removed.
==============
other text
<other HTML>
<table>
bold underlined italic text
</table>
other text
<other HTML>
=============
Any help is greatly appreciated!
I have a paragraph, in that, some of the texts are surrounded with a specific html tag. I need to to find the text which are not surrounded by that specific html tag.
For example
AVG Antivirus for Smartphones and Tablets detects harmful apps and SMS.
<font color='black'>AVG</font> Mobilation™ AntiVirus Pro for Android™ is a mobile security
solution that helps protect your mobile device from viruses, malware, spyware and online
exploitation in real-time. avg blah blah...
I want to find the word AVG (case insensitive) which is not surrounded by <font color='black'> </font>. It can be part the word or single whole word. In the case of part of the text, the whole word containing the word AVG should not surrounded by that html tag
How can I do it with Java?