473,320 Members | 1,879 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.

Regexp to filter style from HTML

17
I'm trying to strip out the "style" attribute from a bit of user input. If the user input is $input, why wouldn't the following, given
Expand|Select|Wrap|Line Numbers
  1. <tag style="blah" href="site">Content</tag>
leave me with
Expand|Select|Wrap|Line Numbers
  1. <tag href="site">Content</tag>
It doesn't take out anything at all!

Expand|Select|Wrap|Line Numbers
  1. $strip_regexp = array('/(.*)style=\".*\"(.*)/', '/(.*)style=\'.*\'(.*)/');
  2. $input = preg_replace($strip_regexp, "$1$2", $input); // apply strip_regexp
Mar 18 '09 #1
0 954

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

Similar topics

5
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could....
1
by: eysteinbye | last post by:
I have a problem with my RegExp. I need to replace some URLs with other URLs. I am using a URL-rewrite filter). The problem is that when the RegExp match just parts of the string, it does a...
0
by: | last post by:
Hello, Is anyone have an example of RegExp expression to parse .EML files (Email Message)? I need to extract headers, HTML body, Textual body and attachments if any exists. I did some...
2
by: Tamas Nyilanszky | last post by:
hi, i need to filter (e.g.) the number 149, 1307 and 3100 from a line like this one: <td id=l2 title=149>1307/3100</td> so i will be able to split that string with reg.split() and receive...
6
by: Christoph | last post by:
I'm trying to set up client side validation for a textarea form element to ensure that the data entered does not exceed 200 characters. I'm using the following code but it doesn't seem to be...
6
by: runsun pan | last post by:
Hi I am wondering why I couldn't get what I want in the following 3 cases of re: (A) var p=/(+-?+):(+)/g p.exec("style='font-size:12'") -- // expected
1
by: bdbeames | last post by:
I have a form where I would like to perform some validation using a javascript function. I cant' figure out the RegExp. function is_number(target) { target.value = trim(target.value); ...
4
by: Matt | last post by:
Hello all, I have just discovered (the long way) that using a RegExp object with the 'global' flag set produces inconsistent results when its test() method is executed. I realize that 'global'...
11
by: petvampire | last post by:
hey there. im new to the coding side of asp as i learnt html before hand. What im trying to do is intergreat a smilie filter in to a small chat i building for me and and some mates. The chat is using...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.