Hello
I want a regular expression which will ignore the sentence containing "XYZ" character.
I am using this but this is not working
"(.+[^XYZ])"
Thanks in advance
Trying to replace the first 12 digits of credit card numbers with X's in a predictable blob of text that contains the string:
Credit Card Number: 1234123412341234
Here's my PHP function:
preg_replace('/Credit Card Number: ([0-9]{12})/','Credit Card Number: XXXXXXXXXXXX',$str);
Help?
Hi,
I'm trying to preg_replace charset=blablabla; and charset=blablabla" with charset=utf-8; and charset=utf-8". Please see ; = and " characters, and of course searched string can be lower/uppercase.
Can you help me?
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?
This is a great regular expression for dates... However it hangs indefinitely on this one page I tried... I wanted to try this page ( http://pleac.sourceforge.net/pleac%5Fpython/datesandtimes.html ) for the fact that it does have lots of dates on it and I want to grab all of them. I don't understand why it is hanging when it doesn't on other pages... Why is my regexp hanging and/or how could I clean it up to make it better/efficient ?
Python Code:
monthnames = "(?:Jan\w*|Feb\w*|Mar\w*|Apr\w*|May|Jun\w?|Jul\w?|Aug\w*|Sep\w*|Oct\w*|Nov(?:ember)?|Dec\w*)"
pattern1 = re.compile(r"(\d{1,4}[\/\\\-]+\d{1,2}[\/\\\-]+\d{2,4})")
pattern4 = re.compile(r"(?:[\d]*[\,\.\ \-]+)*%s(?:[\,\.\ \-]+[\d]+[stndrh]*)+[:\d]*[\ ]?(PM)?(AM)?([\ \-\+\d]{4,7}|[UTCESTGMT\ ]{2,4})*"%monthnames, re.I)
patterns = [pattern4, pattern1]
for pattern in patterns:
print re.findall(pattern, s)
btw... when i say im trying it against this site.. I'm trying it against the webpage source.
How can I match the following pattern?
"anything123.anythingelse"
Alphanum of any length, with exactly 1 "." in the middle, and then alphanum of any length?
Thanks.
In this text:
warning here
there are several types of warnings
in this string warning.gif
at the end warning
end of line warning
I want to match every warning except warning.gif.
I cannot seem to get it to include the last one that has no character (control or otherwise) after it.
using warnings?[^\.] gets what I want except for the last warning (on the last line). I think because there is no character at all after. How can I get it to include that one?
Hello all,
I am really stuck with these 2 question for over 2 days now. trying to figure out what the question means.... my tutor is out of town too....
write a regular expression for the only strings that are not generated over {a,b} by the expression: (a+b)*a(a+b)*. explain your reasoning.
and i tried the second question, do you think is there any better answer than this one?
what is regular expression of set of string that contain an odd number of a's or exactly two b's................(a((a|b)(a|b))*|bb).... coz i know to represent any odd length of a's, the RE is a((a|b)(a|b))*
$('#customerAddress').text().replace(/\xA0/,"").replace(/\s+/," ");
Going after the value in a span (id=customerAddress) and I'd like to reduce all sections of whitespace to a single whitespace. The /\s+/ whould work except this app gets some character 160's between street address and state/zip
What is a better way to write this? this does not currently work.
Need to replace a domain name on all the links on the page that are not images or pdf files.
This would be a full html page received through a proxy service.
I am using ruby 1.8.7. I am not using rails.
How do I find all the links which are not already in anchor tag.
s = %Q{ <a href='www.a.com'><b>www.a.com</b></a> www.b.com <div>www.c.com</div> }
The output of above string should be
www.b.com
www.c.com
I know "b" tag before www.a.com complicates the case but that's what I have to work with.
Hi,
I do the validation through configuration files.
But, RegexValidator does not work properly.
This Validator not disciplined even to unknown regular expression!!
Do you know about this problem?
Many thanks!!!
I need to get all characters between '(' and ')' chars.
var str = "dfgdgdfg (aaa.bbb) sfd (c) fdsdfg ( ,ddd (eee) )";
In this example, I need to get 3 strings:
(aaa.bbb)
(c)
( ,ddd (eee) )
What pattern I have to write? Please, help.
Hi,
How can I take a line like this:
Digital Presentation (10:45), (11:30), 12:00, 12:40, 13:20, 14:00, 14:40, 15:20, 16:00, 16:40, 17:20, 18:00, 18:40, 19:20, 20:00, 20:40, 21:20, 22:00, 22:40, 23:10, 23:40.
And match all the 24 hour times so I can convert to a more human readable format using date()?
Also I want to match times in the 24:00-24:59 range too
Thanks!
<SPAN id=spanD121C150D2 style="BACKGROUND-COLOR: antiquewhite" CategoryID="1" MessageID="2316" refSpan="">
<SPAN id=span1CE69EDE12 style="BACKGROUND-COLOR: blue" CategoryID="2" MessageID="2316" refSpan="">platnosci inny srodkiem platnosci. DC - zakup paliwa na stacji benzynowej 101-500 (150 zl). 27
</SPAN>
</SPAN>
I have a string like above.
If the selected text is "srodkiem ", is it possible to get the relevant span tag?
Is this possible using a regular expression?
I'm desperately searching for regular expressions that match these scenarios:
1) Match alternating chars
I've a string like "This is my foobababababaf string" - and I want to match "babababa"
Only thing I know is the length of the fragment to search - I don't know what chars/digits that might be - but they are alternating.
I've really no clue where to start :(
2) Match combined groups
In a string like "This is my foobaafoobaaaooo string" - and I want to match "aaaooo". Like in 1) I don't know what chars/digits that might be. I only know that they will appear in two groups.
I experimented using (.)\1\1\1(.)\1\1\1 and things like this...
how can i much the sentense, if it doesn't contain none of {word1,word2,word3}
where i must put ^ symbol?
i think it must looks like this
^([^word1|word2|word3])$
but it doesn't work.
could you help? thanks
I need to convert
$text = 'We had <i>fun</i>. Look at <a href="http://example.com">this photo</a> of Joe'
to
$text = 'We had fun. Take a look at this photo (http://example.com) of Joe'
All HTML tags are to be removed and the href value from <a> tags needs to be added like above.
What would be an efficient way to solve this? Any code snippet would be great.
The message has detection report:
<detection_report>
Test 1
Test 2
Test 3
</detection_report>
---------------------------------------------
Have a nice day
I want to select portion between <detection_report> tags, including these two tags.
I have written following code.
The message has detection report\:((.|\n|\r)+)(\<\/detection_report\>)
but its not working. Can anyone help me with this.
<table >
<tr>
<td colspan="2" style="height: 14px">
tdtext1
<a>hyperlinktext1<a/>
</td>
</tr>
<tr>
<td>
tdtext2
</td>
<td>
<span>spantext1</span>
</td>
</tr>
</table>
This is my sample text how to write a regular expression in C# to get the matches for the innertext for td, span, hyperlinks.
In Perl I would do something like this for taking different fields in a regexp, separating different fields by () and getting them using $
foreach $line (@lines)
{
$line =~ m/(.*?):([^-]*)-(.*)/;
$field_1 = $1
$field_2 = $2
$field_3 = $3
}
How could I do something like this in Python?
Let's say I want to look for
<Address>
<Street>Windsor</Street>
</Address>
and I do not want to return
<Address>
<Number>15</Number>
<Street>Windsor</Street>
</Address>
i.e. I am looking for addresses where the Address node does not contain a number tag.
I tried things like <Address>(?!Number)</Address> or <Address>.*?(?!Number).*?</Address> but can't quite figure it out :-(
Any ideas?
TIA
eddiec :-)
Supposed I have the following string:
string str = "<tag>text</tag>";
And I would like to change 'tag' to 'newTag' so the result would be:
"<newTag>text</newTag>"
What is the best way to do it?
I tried to search for <[/]*tag but then I don't know how to keep the optional [/] in my result...
I want to transform a line that looks like this:
any text #any text# ===#text#text#text#===#
into:
any text #any text# ===#texttexttext===#
As you can see above I want to remove the # between ===# and ===#
The number of # that are supposed to be removed can be any number.
Can I do this with sed?