-
Posts
14,780 -
Joined
-
Last visited
-
Days Won
43
Everything posted by .josh
-
fair enough. This should work: /^[a-zA-Z0-9](?:[a-zA-Z0-9]|(?!--)-){0,48}[a-zA-Z0-9]$/
-
Look, here's a canned answer that works for your canned example. Good luck in your endeavors to make it work 100% of the time when you decide to add arbitrary paragraphs to it. If you wanna be a dumbass and not understand that what you're wanting to do is not possible, then that's your business. $string = <<<EOF The quick brown fox jumped over the lazy dog. What do you think? I don't think that's very impressive! Blah. Okay that's it EOF; preg_match_all('~(?<=[.?!]|^).*?(?:[.?!]|$)~s',$string,$matches); echo "<pre>"; print_r(array_map('trim',$matches[0]));
-
I mean look at your own example: "Blah. Okay that's it" why is that considered one sentence to you? How would you suggest regex decide that that should be one sentence and not two? The answer is that IT CAN'T.
-
No, the problem is that you are asking for a pattern to match something that can't be matched. So there's no "fixing" what you came up with or writing a pattern that will work. The end. The problem is that you can't seem to get that through your head.
-
give me a legit reason why you need a one line regex solution.
-
you can add range to the regex but it's more optimal to use the strlen condition first. strlen is a lot faster than using {2,50} in a pattern so it's better to pre-qualify the string like that, instead of putting it in the regex. If it doesn't validate on the strlen condition, you also save php the work of having to go through the rest of the regex. Regex is a powerful tool, but wherever possible, you should always use built-in functions.
-
I read your post just fine. The point was that no matter how you try to slice it, there's no way to do that with 100% accuracy, or even 50% accuracy. You are not very close to solving it as you claim, and I gave you factual, not philosophical reasons why. You just think you are because you are using canned examples in your testing. I will agree that advising you about attempting the impossible may be a question of philosophy, but telling you that it can't be done is not a matter of philosophy, but of fact. If you wanna nonetheless keep hammering away at it then suit yourself. You said you don't want a philosophical debate, but asking which makes more sense is a matter of philosophy. A single sentence by itself will probably make less sense than the entire paragraph, as far as conveying a thought, in the same way that half a sentence will not make sense compared to the full sentence. The point here is that you cannot use code to automatically generate something that "makes sense" in a human way. You ask me which "makes more sense" well to me it makes more sense to cut off at exactly x characters and trail it with "..." or something so that you don't have to worry about variable length matches messing up styling.
-
function validateString($string) { if (strlen($s) > 1 && strlen($s) < 51) { if (preg_match('~^[a-z0-9]+-?[a-z0-9]+$~i',$s)) return true; } return false; }
-
yeah but... I mean, I can clean a cut and put a bandaid on it. That doesn't make me a doctor, nor should I try to be a doctor with that skill level, even though that's where "the money is at." People will quickly realize I'm trying to pass myself off as a doctor when I don't know jack shit about doctoring. And then they are gonna be like "hmm...he claims to be a doctor when clearly he knows nothing about being a doctor, so why should we believe him when he claims he can do these other things?" Same principle applies here. You are offering design service when you are not good at design. If you were good at design, you wouldn't be asking for design advice. So here you have this crappy business card design. Probably a crappily designed site if this card is any indication of your skills, and yet you are offering up design services. People will be like "wtf?" and then probably assume that your skill level is not up to par for the other services you offer. I'm not saying you suck just to say you suck. I'm advising you to get to the point where you are good at design, before advertising services for it, because it will hurt your business if you don't.
-
You're fighting a lost cause. No point in looking for capital letters, as capital letters are used for any number of things in the middle of a sentence, not just the first word. Same with punctuation; periods can be used as abbreviations in the middle of the sentence, virtually any of the sentence ending punctuations can be used when quoting someone, etc... No point in looking for newlines either, as ideally there shouldn't even be newline characters in the paragraph except maybe at the end. You're only hope for getting it accurate is to force a certain standard when it is being input in the first place. Like forcing the user to mark the end of a sentence with a special non-standard char(s).
-
if you are looking for an array of ONLY dir names, excluding . and .. then glob will indeed work for you: $dirs = glob('*',GLOB_ONLYDIR);
-
How to click on a file to download it, not open it
.josh replied to tekrscom's topic in PHP Coding Help
okay but who has access to it if they login? Random registered user? Admin who have server access anyway? Depending on who is able to login and access the page, that might not be good enough. -
I'm also wondering why you are asking for design advice when "design" is one of your services listed on your business card...
-
How to click on a file to download it, not open it
.josh replied to tekrscom's topic in PHP Coding Help
Yes there are php functions that allow you to make zips. Though I think PFM's method where you point to a script that dynamically outputs the content with headers would be the better choice. -
How to click on a file to download it, not open it
.josh replied to tekrscom's topic in PHP Coding Help
You can't. That's something built into the browser. You can offer the file up in a form that the browser will download, like a zip. But you can't make someone's browser download vs. view something like a .txt file or other file that the browser normally renders. -
It looks like the back of a cheap brochure you pick up at a convention. From the 80's. edit. Okay maybe a little more credit. From early 90's.
-
I bet she could find all your happy spots though. without a map.
-
remove enctype="text/plain" from your form tags
-
you cannot overwrite or erase a function previously defined.
-
there is an example of figuring out the date in the future in the manual. date
-
well creating your own is pretty easy. Just create a database table with 2 columns one called "url" another called "hits". Then on every page on your site you would basically update your table with a basic query like [pre] $url = "page url or specific name/title here"; query to send to db: "update tablename set hits=hits+1 where url='$url'" [/pre] and then on your "Top 10" page, you would use a query like [pre] "select url from tablename order by hits desc limit 10" [/pre]
-
Is this some kind of "Top 10" list you want to have displayed on your actual website, with up-to-date info? Or is this for some kind of internal reporting purpose(s)?