-
Posts
1,832 -
Joined
-
Last visited
-
Days Won
3
Everything posted by salathe
-
What changed between the old and new servers?
-
So you've been working on this problem for 20 days and are still stuck on it; or have you just not tried anything else? (Sorry to press home on this, it just seems odd.)
-
Glad you got it sorted. Next time please be sure to give accurate sample data/code, to help us to help you.
-
Replace Disp "Text" with "Text"_ using preg_replace
salathe replied to qureshi's topic in Regex Help
Be aware that given the example string, there will be Carriage Return (\r or ASCII 13) characters left floating around since the Windows-style line ending (\r\n) is used. -
I cannot reproduce your output, nor can I see in your code how on earth that text can get matched. See a live running example of your code (behaving properly) -- http://codepad.viper-7.com/W32a4S Are you sure you're not just doing something dumb like echoing the original string rather than what was matched?
-
Calling header('Location: ...') does not immediately redirect; the remainder of the page is still executed. You should call exit immediately after the call to header if you want processing to stop and the redirect to occur at that point.
-
The second input cannot output with a double-quote since the regex in your code cannot, ever match a double-quote. Please, write show us a sample script (like what you have already, but with $string(s) being defined) that I can run, which gives you that trailing double-quote character in the match.
-
See below.
-
What have you tried so far?
-
web4, did you get this sorted out? Of the two patterns offered, I'd go with cags' (since, it would work as you want).
-
Neither of those inputs should output anything since the regex in your code looks for https
-
A common approach would be to perform a two-step replacement. On the first pass, replace the matching strings with some value that will serve as a placeholder. On the second pass, replace those placeholders with the HTML replacement that you want. It would be possible to check for the existence of the anchor tag wrapping the string, so everything could be done in one replacement (as you are currently doing) but that might turn what is currently a complicated, messy regex into something even more complicated and messy. Since you're currently running through the replacements one-at-a-time in the order that they come from in the database query, are you concerned at all about matching the longest phrase first (so "The Adventure Company" will always get replaced in preference to "adventure")?
-
Show us a short sample code which reproduces the issue of not rejecting subject strings containing symbols. The only non-alphanumeric symbol that should be allowed by that regex (in PHP/PCRE) is a trailing newline character.
-
Show us some sample string and code (may be the same as the previous snippet) which does not behave as you want, then be precise about how you want it to behave. Currently, the code and string in your next-to-last post work as advertised.
-
What makes you think that?
-
The pattern that you posted will stop at a quote.
-
ajfrojojo, that's not how preg_match works; please read the appropriate manual page to see why. There is, however, a very similarly named function which would help lots with what you're after; I'll leave you to discover that on your own after reading the link above.
-
preg_replace loop? (aka, capture each individual replacement)
salathe replied to techiefreak05's topic in PHP Coding Help
Personally I'd separate the two events: 1. replacing @text with HTML markup, is entirely separate from 2. compiling a list of users to send an email to. -
Please ask a question.
-
It looks like you're not really grasping the concept of OOP clearly at all, instead you're essentially wrapping a bunch of procedural behaviour (discrete functions) within a class. Those different parts that you mention should belong in very different, separate classes; just to give a couple of examples, logging in is all about authentication whereas restriction is about authorization -- two separate entities right there! Getting/sending PMs is entirely unrelated to retrieving a user's age, so should definitely not belong in the same class. Etc..
-
It sounds like you're wanting to do too much with a single class. Can you give a concrete example of a class that you have which you think would benefit from being spread across multiple files, and explain why you think so?
-
Instead of using regex, you could use a function which is designed to parse formatted strings: sscanf $subject = '2009/06/28 22:54:59 administrator 13 1'; $reg = sscanf($subject, '%d/%d/%d %d:%d:%d %s %d %d'); The format string could be more, or less, precise depending on your needs (e.g. if you need the leading zero for the date/time values less than 10).