473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

preg_replace(not all tags) (Answer)

6
I found this post by Google with question:
http://bytes.com/topic/php/answers/1...e-not-all-tags "I need to replace all possible html tags in user input but don't want to
replace bold and italic start and end tags, so I made folowing line, but
it replaces only "one-letter-tags" like paragraf or underline tag, it
doesn't replace body, div, span tags...
Can anyone help me with this?
Expand|Select|Wrap|Line Numbers
  1. $txt = preg_replace('/<\/?[^bi]>/i', ' ', $txt);
"
May be my answer helps to another users:

Just type
Expand|Select|Wrap|Line Numbers
  1. $txt = preg_replace('/\<\/?[^bi][^>]*\>/sU', ' ', $txt);
For tags with 2 and big letters (br,img,hr) try this:
Expand|Select|Wrap|Line Numbers
  1. $txt = preg_replace('/\<\/?(?!br|img|hr)\b[^>]*\>/sU', ' ', $txt);
Nov 4 '13 #1
1 1582
zmbd
5,501 Expert Mod 4TB
T.H.M.C: I asked CnapoB to start another thread with reference to an old thread due to posting issues; thus, I respectfully ask that CnapoB's post be treated as a continuation of the old thread for commenting, peer review etc...
-z
Nov 4 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: varois83 | last post by:
Hi I am fairly new to PHP/mysql and was reading an online tutorial and learned that my short tags weren't enabled. At this time I have no need for them, my setup apache/mysql/php runs on my PC...
8
by: Hostile17 | last post by:
Consider the following HTML. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta...
15
by: Val | last post by:
Any experts on mailto: tags? I want to set a link so that the subject and some of the body of the email is filled in. This is easy for simple text, although you need to use %20 for spaces: <a...
7
by: Dexter | last post by:
I need to save a text with html tags in a SQL Server database. I'm using server.htmlencode, but don't function. A error is generate. Somebody know how to resolve this problem? Dexter
0
by: Robert Seidl | last post by:
I saw that VB .Net 2003 has some tools for easily reading metadata information present in some TIFF and JPG files, eg. ---------------------------------------------------------------- .... Dim b...
5
by: wolf_y | last post by:
My question is simply: under what conditions will empty tags of the form <MOM></MOM> pass schema validation? Of course, the mirror question is: under what conditions will empty tags fail...
8
by: Philip Ronan | last post by:
Hi, I recently discovered that Google's mobile search robot doesn't understand the "robots" Meta tag. Here's an example: ...
8
by: azjudd | last post by:
Thank you in advance for your help on this one. I'm using named anchor tags on a FAQ page with questions listed at the top and answers below; a standard jump-to feature. However, anytime an anchor...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.