Regex Question

I am trying to figure out regular expressions but can’t seem to get this working.

I would like to append a form to an html body tag but I need it to maintain whatever is contained within the body tag;


<body {whatever falls in the tag}>


<body {whatever falls in the tag}>  <form name='form'><input......></form>

how would i do this using regular expressions?

So, I take it you’re trying to use regular expressions to… find the string location to add the text? Are you having problems with… what expression to use? The way to use the result?

(Not… really sure why you’re doing that. Much easier ways to accomplish that.)

That is correct. I’m trying to add a a form directly after the <body> tag but since the body tag may contain other attributes I need this to work regardless what, if any, attributes the body tag may have.

I thought a preg_replace would be the best option but if there are better options, than I’m all for that.

check out the [FPHP]DOM[/FPHP] classes of objects. Injecting a block should be fairly straightforward once you can walk the HTML as blocks.

Still not entirely sure why you’re wanting to do this programatically instead of just… inserting the form into the HTML?