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.
I'm trying to extract the # of minutes from a text field using Oracle's REGEXP_SUBSTR() function.
Data:
Treatment of PC7, PT1 on left. 15 min.
15 minutes.
15 minutes
15 mins.
15 mins
15 min.
15 min
15min
15
In each case, I'm hoping to extract the '15' part of the string.
Attempts:
\d+ gets all of the numeric values, including the '7' and '1', which is undesirable.
(\d)+(?=\ ?min) get the '15' from all rows except the last.
(?((\d)+(?=\ ?min))((\d)+(?=\ ?min))|\d+), an if-else statement, doesnt' match anything.
What is wrong with my if-else statement?
Hi,
I've a free text field on my form where the users can type in anything. Some users are pasting text into this field from Word documents with some weird characters that I don't want to go in my DB. (e.g. webding font characters) I'm trying to get a regular expression that would give me only the alphanum and the punctuation characters.
But when I try the following, the output is still all the characters. How can I leave them out?
<html><body><script type="text/javascript">var str="???????";document.write(str.replace(/[^a-zA-Z 0-9 [:punct]]+/g, " "));</script></body></html>
After seeing several threads rubbishing the regexp method of finding a term to match within an HTML document, I've used the Simple HTML DOM PHP parser (http://simplehtmldom.sourceforge.net/) to get the bits of text I'm after, but I want to know if my code is optimal. It feels like I'm looping too many times. Is there a way to optimise the following loop?
//Get the HTML and look at the text nodes
$html = str_get_html($buffer);
//First we match the <body> tag as we don't want to change the <head> items
foreach($html->find('body') as $body) {
//Then we get the text nodes, rather than any HTML
foreach($body->find('text') as $text) {
//Then we match each term
foreach ($terms as $term) {
//Match to the terms within the text nodes
$text->outertext = str_replace($term, '<span class="highlight">'.$term.'</span>', $text->outertext);
}
}
}
For example, would it make a difference to determine check if I have any matches before I start the loop maybe?
Hello,
I've been trying to find a string in PHP that matches something like this:
Currently I've tried something like this;
<()\?php eval(^
but it dosen't seem to get the string correctly.
I'm trying to extract some results from a download manager, the format is:
[#8760e4 4.3MiB/40MiB(10%) CN:2 DL:4.9MiB ETA:7s]
what I'd like to extract from the above example, would be an array that looks like this:
['4.3','MiB','40','MiB','10%','4.9','MiB','7','s']
I've tried to split this in various combinations, but nothing seems to be right. Would anyone happen to know how to do this or be able to offer suggestions?
Thank you!
i have this code for get data from textfield:
<script type="text/javascript">
var mod=document.getElementById("mod").value;
ajax(mod);
function callback() {
if(ajaxObj(mod) {
document.getElementById("divResult").innerHTML=ajaxObj.responseText;
});
};
</script>
and this one for search character:
<script>
var str="KD-R435MUN2D";
var matches=str.match(/([EJU]).*(D)/i);
if (matches) {
var firstletter = matches [1];
var secondletter = matches [2];
var thirdletter = matches [3];
alert(firstletter + secondletter + thirdletter);
}else{
alert (":(");
}
</script>
how to combine both?please help...
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
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?
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?
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?
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?
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.
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.
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.
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,
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!
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!!!
<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