I have a string;
text="Label"
and I need to replace it to:
text="{resourceManager.getString('trad', 'Label')}"
What would be the easiest expression to do this?
I am trying to refine a preg_match_all by finding the second occurrence of a period then a space:
<?php
$str = "East Winds 20 knots. Gusts to 25 knots. Waters a moderate chop. Slight chance of showers.";
preg_match_all ('/(^)((.|\n)+?)(\.\s{2})/',$str, $matches);
$dataarray=$matches[2];
foreach ($dataarray as $value)
{ echo $value; }
?>
But it does not work: the {2} occurrence is incorrect.
I have to use preg_match_all because I am scraping dynamic HTML.
I want to capture this from the string:
East Winds 20 knots. Gusts to 25 knots.
Hi,
In Python script,for every method definition in some C++ code of the form:
return_value ClassName::MethodName(args)
{MehodBody}
,I need to extract three parts: the class name, the method name and the method body for further processing. Finding and extracting the ClassName and MethodName is easy, but is there any simple way to extract the body of the method? With all possible '{' and '}' inside it? Or are regexes unsuitable for such task?
Hi!
i would like to avoid texts like this one: height="49" with a regular expresion.
I tought in .replaceAll("\s*="*"","");
(replaceAll is used as a method in a java class), but eclipse don't allowed me to do that.
Any other suggestion??
tx!
i have a term 1/temperatoA,2/CelcieusB!23/33/44,55/66/77 and i want only extract word temperatoA and CelcieusB, i have this regular expression (\d+/(\w+),?)*!
but i get only 1/temperatoA,2/CelcieusB!
why!!! please
Hello friends,
How can i prevent user to enter any url or link in contact form text area, i have tried it with this but its not working -
if (!isset($_POST['submit']) && preg_match_all('/<a.*>.*<\/a>/', $_POST['query']))
{
echo "<h1 style='color:red;'>HTML Tag Not allowed </h1>";
}
else {
//sendmail
}
Please help me
Suppose I have variables
$x1 = 'XX a b XX c d XX';
$x2 = 'XX a b XX c d XX e f XX';
I want a regular expression that will find each instance of letters between XX. I'm looking for a general solution, because I don't know how many XX's there are.
I tried using /XX(.*?)XX/g but this only matches "a b" for x1 and "a b", "e f" for x2 because once the first match is found, the engine has already read the second "XX".
Thanks for any help.
I have asp:RegularExpressionValidator with ValidationExpression="\d+{1,4}(?:[.,]\d{1,4})?" but it doesn't' work, parser throws ArgumentException:
parsing "\d+{1,4}(?:[.,]\d{1,4})?" -
Nested quantifier {.
Where is my mistake? I want to allow strings like xxxx,xxxx - from 1 to 4 digits and decimal digits are not required, e.g.: 1000, 99,99, 0,2498, etc.
i had string like this in javascript
var str = "This is my test string is Ingrédients";
the substring "Ingrédients" can be also as "Ingredients"
how to get the index of substring "Ingrédients" from the above string
by applying regular expression ( Ingr[ée]dients )
I'm trying to use python to copy a tree of files/directories.
is it possible to use copytree to copy everything that ends in foo?
There is an ignore_patterns patterns function, can I give it a negated regular expression? Are they supported in python?
eg.
copytree(src, dest, False, ignore_pattern('!*.foo'))
Where ! means NOT anything that ends in foo.
thanks.
Can someone explain what the 'e' flag does, or link me to somewhere that does? I couldn't find anything via google.
Example:
preg_replace("/a(b?)c/e", "search_foo_term('\$1')", $str);
I am trying to adapt a php application to handle non-latin scripts (specifically: Japanese, simplified Chinese and Arabic). The app's data validation routines make frequent use of regular expressions to check input, but I am not sure how to adapt the \w character type to other languages without installing additional locales on the system (which I cannot rely on).
Previous developers to have worked on the app have simply added needed characters to the regexes as the number of languages we supported grew (you frequently see "[\wÀÁÂÃÄÅÆÇÈÉ... etc" in the code), but I can't really do this for all the alphabets I need to support now.
Does anybody out there have some advice on how to tackle this?
Hy i have to test if a string begins with 00 or with +
Say i have the string 0090 or +41 if the string begins with 0090 return true, elseif string begins with +90 replace the + with 00 else return false
The last two digits can be from 0-9
How do i do that in php?
I hope i could explain my question clear?
I have the following line of code which works well:
$("a.grouped_elements[href$=.jpg],a.grouped_elements[href$=.png],a.grouped_elements[href$=.gif]").fancybox();
Problem is, if the href is .JPG it doesn't work it only works with .jpg. How can I make the above case insensitive so either all caps or no caps or a mix all match for the file extension?
Thanks
2010-June-11
<remove>2010-June-2</remove>
<remove>2010-June-3</remove>
2010-June-15
2010-June-16
2010-June-17
2010-June-3
2010-June-2
2010-June-1
I'm trying to find all instances that are between the <remove> tags
This is what I have:
$pattern = "/<remove>(.*?)<\/remove>/";
preg_match_all($pattern, $_POST['exclude'], $matches);
foreach($matches as $deselect){
foreach ($deselect as $display){
echo $display."<br />";
}
}
This is what it returns:
2010-June-2
2010-June-3
2010-June-2
2010-June-3
Why is it doubling up, and how do I prevent that?
Hi,
I have the 12 html pages. and all this pages are loads when the left navigation bar link clicked. in this, i need to add a class to the current link, which is clicked and loaded the page. i tried with this:
$(function(){
$('#container li a').click(function(){
$('#container li a').removeClass('current');
var pathname = (window.location.pathname.match(/[^\/]+$/)[0]);
var currentPage = $(this).attr('href');
if(currentPage==pathname){
$(this).addClass('current');
}
else{
alert('wrong');
}
// alert(pathname+' currentPage: '+currentPage);
})
})
it works, but on page load, the class is removed, i don't know why it's happening..
any help?
I have a static library that is compiled with gcc 3.4.2. I am building a shared library that relies on this static lib. I will be building this shared library (.so) with gcc 4.2.2. I was wondering what are the potential pitfalls of using the 3.4.2 static library in a gcc 4.2.2 shared library?
I'm trying to use a regular expression as below:
preg_match_all('|<table.*</table>|',$html,$matches, PREG_SET_ORDER);
But this is not working, and I think the problem is the new line inside the string $html.
Could someone tell me a work around?
I'm rubbish at Regular Expressions, really!
What I'd like is to split a string containing a CCS property value into an array of [string,value,unit].
For example: if I supplied the .split() method with 1px it'd return ["1px",1,"px"]. If I were to supply, similarly, 10% it'd return ["10%",10,"%"].
Can this be done?
I appreciate all your help!
Hello.
I have a file input in a form that uploads a mp3 file, but I´d like to detect conflictive characters to my system in the filename, like ! @ or any other.
All codes I´ve found replace these characters, but I just want to detect them to alert the user. I think it will be easy with regular expressions, but I dont know about them.
I´m using jquery/javascript.
Thanks in advance for your help
Edit to improve my problem description:
I´m working in a CodeIgniter application that allows user to upload mp3 files to the server.
I use jQuery to manage client side forms. The CI upload class converts spaces in the file name to underscores and everything works.
But testing the application I uploaded a mp3 file with a (!) in the name, and I got troubles with it.
I just want to insert a javascript conditional before the file is uploaded to evaluate if the user´s filename contains a (!) (or any other I´d like to add later) to ask for the file to be renamed if it does.
I have the following line of code which works well:
$("a.grouped_elements[href$=.jpg],a.grouped_elements[href$=.png],a.grouped_elements[href$=.gif]").fancybox();
Problem is, if the href is .JPG it doesn't work it only works with .jpg. How can I make the above case insensative so either all caps or no caps or a mix all match for the file extenstion?
Thanks
I have a version number with 3 digits as a String,
var version = "1.2.3";
and would like to compare it to another version. To see if version is newer than otherversion,
var otherVersion = "1.2.4";
How would you do it?
EDIT
i have something like this in a file:
imagecolor=0
arrayimagecolorcopy=0
arrayimagecolorcopy3d=0
when i use sed -i -e 's/imagecolor=0/imagecolor=1/' it will change 1 and 2 line. But i only want it to replace first line.
i also tried sed with \< \ and \b \b, but no luck. Could it be the '=' sign? Do we have something like -w as in grep command?
Thank you.