here are some canned/stored grep patterns i use all the time... i have a 
bunch. all of the ones related to forms start with FORMS:, all of the one 
related to php start with PHP:, etc.



FORMS: generate radio buttons
   USAGE: any amount of field names, one per line. select all and then 
REPLACE ALL - selection only
   FIND: ^([^\r]+)\r
   REPLACE ALL: <INPUT NAME="\1" TYPE="radio" VALUE="Y"> Yes<BR>\r<INPUT 
NAME="\1" TYPE="radio" VALUE="N"> No<BR>\r\r

SUCH AS:
do i love bbedit?
could i imagine using any other program than bbedit?
where's my winning lottery ticket already?!?!?

WHICH RESULTS IN:

<INPUT NAME="do i love bbedit?" TYPE="radio" VALUE="Y"> Yes<BR>
<INPUT NAME="do i love bbedit?" TYPE="radio" VALUE="N"> No<BR>

<INPUT NAME="could i imagine using any other program than bbedit?" 
TYPE="radio" VALUE="Y"> Yes<BR>
<INPUT NAME="could i imagine using any other program than bbedit?" 
TYPE="radio" VALUE="N"> No<BR>

<INPUT NAME="where's my winning lottery ticket already?!?!?" TYPE="radio" 
VALUE="Y"> Yes<BR>
<INPUT NAME="where's my winning lottery ticket already?!?!?" TYPE="radio" 
VALUE="N"> No<BR>





FORMS: init post vars from a list of field names
   USAGE: any amount of field names, one per line. select all and then 
REPLACE ALL - selection only
   FIND: ^([^\r]+)\r
   REPLACE ALL: \tif ( isset($_POST['\1']) ) {\r\t\t$\1 = 
$_POST['\1'];\r\t} else {\r\t\t$\1 = "";\r\t}\r\r

SUCH AS:
wombat
toaster_oven
lumbago

WHICH RESULTS IN:

if ( isset($_POST['wombat']) ) {
$wombat = $_POST['wombat'];
} else {
$wombat = "";
}

if ( isset($_POST['toaster_oven']) ) {
$toaster_oven = $_POST['toaster_oven'];
} else {
$toaster_oven = "";
}

if ( isset($_POST['lumbago']) ) {
$lumbago = $_POST['lumbago'];
} else {
$lumbago = "";
}






FORMS: init post AND session vars from a list of field names
   USAGE: any amount of field names, one per line. select all and then 
REPLACE ALL - selection only
   FIND: ^(.+)\r
   REPLACE ALL: \t$the_\1 = $_POST['\1'];\r\t\t$_SESSION['\1'] = \$the_\1;\r

SUCH AS:
wombat
toaster_oven
lumbago

WHICH RESULTS IN:

$the_wombat = $_POST['wombat'];
$_SESSION['wombat'] = $the_wombat;
$the_toaster_oven = $_POST['toaster_oven'];
$_SESSION['toaster_oven'] = $the_toaster_oven;
$the_lumbago = $_POST['lumbago'];
$_SESSION['lumbago'] = $the_lumbago;








On Thursday, February 23, 2017 at 11:53:14 AM UTC-8, Patrick Woolsey wrote:
>
> Good afternoon folks, 
>
> We just heard from a customer who's written a handy tutorial 
> about creating HTML form fields using BBEdit, so I'm posting a 
> link here for anyone who may find this helpful: 
>
> How to quickly create html form-fields using BBEdit’s GREP 
> search and replace function -- by Ole Kristian Ek Hornnes: 
>
> <
> https://tech.humlesite.eu/2017/02/21/how-to-quickly-create-html-form-fields-using-bbedits-grep-search-and-replace-function/>
>  
>
>
>
> Regards, 
>
>   Patrick Woolsey 
> == 
> Bare Bones Software, Inc.             <http://www.barebones.com/> 
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.

Reply via email to