Skip to content

Tag: php

PHP – Why am I being warned that my regular expression is too large?

I would like to use a regular expression to validate user input. I want to allow any combination of letters, numbers, spaces, commas, apostrophes, periods, exclamation marks, and question marks, but I also want to limit the input to 4000 characters. I have come up with the following regular expression to achi…

Preg_match string inside curly braces tags

I’d like to grab a string between tags. My tags will be with curly braces. So far I have found #<s*?$tagnameb[^>]*>(.*?)</$tagnameb[^>]*>#s This one matches tags with angle brackets <>. I couldn’t figure out how to make it look for curly braces. Eventually I would like to p…

PHP uninclude or reinclude file in interactive mode

I’m testing some database related functions in interactive mode. The first thing I did is to include the testing file, let’s say database.php Then I can make change to the database by a function call. The question is, when I make any changes to database.php, I have exit PHP interactive mode, re-en…

Copy to clipboard from php command line script in Windows 7

I have a php (5.5) script which I run from the command line in Windows 7. Something like this: My question is, is it possible to copy something to windows clipboard from the script? I want users to have some text available in the clipboard after running this script from the command line. How can it be done? A…

Can’t move composer

When I install composer on my mac with: curl -sS https://getcomposer.org/installer | php And then try to move it like this: sudo mv php composer.phar /usr/local/bin/composer it’s telling me: …

Extract email address from string – php

I want to extract email address from a string, for example: From the above string I only want to get email address ruchika@example.com. Kindly, recommend how to achieve this. Answer Try this see demo here Second method See demo here