Hi,
I'm using preg_replace to create urls for modrewrite based paging links.
I use:
$nextURL = preg_replace('%/([\d]+)/%','/'.($pageNumber+1).'/',$currentURL);
which works fine, however I was wondering if there is a better way without having to include the '/' in the replacement parameter. I need to match the number as being between t...
I need to design a function to return negative numbers unchanged but should add a + sign at the start of the number if its already no present.
Example:
Input Output
----------------
+1 +1
1 +1
-1 -1
It will get only numeric input.
function formatNum($num)
{
# something here..perhaps a regex?
}
This f...
I'm trying to strip content titles out of the middle of text strings. Could I use regex to strip everything out of this string except for the title (in italics) in these strings? Or is there a better way?
Joe User wrote a blog post called
The 10 Best Regex Expressions in the category Regex.
Jane User wrote a blog post called
...
I'm trying to come up with the following function that truncates string to whole words (if possible, otherwise it should truncate to chars):
function Text_Truncate($string, $limit, $more = '...')
{
$string = trim(html_entity_decode($string, ENT_QUOTES, 'UTF-8'));
if (strlen(utf8_decode($string)) > $limit)
{
$string ...
This is my test-string:
<img rel="{objectid:498,newobject:1,fileid:338}" width="80" height="60" align="left" src="../../../../files/jpg1/Desert1.jpg" alt="" />
I want to get each of the JSON formed Elements inbetween the rel attribute.
It's working for the first element (objectid).
Here is my ReqEx, which works fine:
(?<=(rel="\{obj...
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, t...
Dear all,
I have data that looks like below, the actual file is thousands of lines long.
Event_time Cease_time
Object_of_reference ...
This has been working for me in 5.8 and 5.10, but in 5.12 my code creates this weird non-qr object:
# running "print Dumper($regex)"
$VAR1 = bless( do{\(my $o = '')}, 'Regexp' );
Whereas printing a qr// not created by my code looks like this:
# running "print Dumper(qr/foo/i)"
$VAR1 = qr/(?i-xsm:foo)/;
My code is basically:
REGEXP...
I was reading ICU documentation and came across this fine advice:
For common tasks like this there are
libraries of freely available regular
expressions that have been well
debugged. It's worth making a quick
search before writing a new
expression.
To which libraries of well-debugged regular expressions do you commonly re...
I want to find files that have "abc" AND "efg" in that order, and those two strings are on different lines in that file. Eg: a file with content:
blah blah..
blah blah..
blah abc blah
blah blah..
blah blah..
blah blah..
blah efg blah blah
blah blah..
blah blah..
Should be matched.
...
An enormous equation. You need to add \left| on the left side of corresponding |. The corresponding | you need to replace with \right|.
Equation
\begin{equation}
| \Delta w_{0} | = \frac{|w_{0}|}{2} \left( |\frac{\Delta g}{g}|+|\frac{\Delta (\Delta r)}{\Delta r}| + |\frac{\Delta r}{r}| +|\frac{\Delta L}{L}| \right)
\end{equation}
[Pr...
sTitle = Regex.Replace(sTitle, @"&\w+;", "")
...
Hi all,
I have written this piece of code that splits a string and stores it in a string array:-
String[] sSentence = sResult.split("[a-z]\.\s+");
However, I've added the [a-z] because I wanted to deal with some of the abbreviation problem. But then my result shows up as so:-
Furthermore when Everett tried to instruct them in basic m...
I've been working on this for a few hours now and can't find any help on it. Basically, I'm trying to strip a SQL string into various parts (fields, from, where, having, groupBy, orderBy). I refuse to believe that I'm the first person to ever try to do this, so I'd like to ask for some advise from the StackOverflow community. :)
To unde...
I want a function that replace each li with an image. This is my code:
$(document).ready(function(){
var tmphref;
var tmpname;
var str = '<a href="' + tmphref + '"><img src="http://www.somesite.com/a/' + tmpname[1] + '/avatar-small.jpg /></a>';
$('#somediv li a').each(function(){
tmphref = $(this).attr("href");
...
i want to know how to get the string from group of string
String j = "<a ............> hai</a>";
i want to get the string of tag of
<a ...> ... </a>
thanks and advance
...
A web page contains lots of image elements:
<img src="myImage.gif" width="180" height="18" />
But they may not be very well-formed, for example, the width or height attribute may be missing. And it also may not be properly closed with /. The src attribute is always there.
I need a regular expression that wraps these with a hyperlink...
I need a regular expression which replaces a string like this
"Myname _MySurename" with "Myname"
that means i just need Myname, so _MySurename should be cut.
i tryed something like "/_*/" but that replaces just the _ (underscore)
how can i do that in PHP ?
...
I have a rewrite that nginx calls like so:
location ~* (css)$ {
rewrite ^(.*),(.*)$ /min/index.php?f=$1,/min/$2 last;
}
And it's used on pages like this:
http://domain.com/min/framework.css,dropdown.css
Works all fine and dandy, but it's not scalable. Adding another element to the URL means I have to directly edit t...
I am trying to figure out a regular expression which matches any string with 8 symbols, which doesn't equal "00000000".
can any one help me?
thanks
...