473,799 Members | 3,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to PREG any character?

moishy
104 New Member
If I wanted to match for instance, all characters that are not in <TAGS>, I would search for all ">ANYTHING< ".

But how do I make that "ANYTHING"?
What will be the PREG for absolutely ANY characer? (except ">" and "<")
Sep 25 '07 #1
3 2277
JeremyMiller
69 New Member
Expand|Select|Wrap|Line Numbers
  1. [^><]+
  2.  
means one or more non-< and non-> character.
Sep 26 '07 #2
moishy
104 New Member
It works for me.
But what do I do after I "htmlentiti ed" it?
I what to find: &gt; ANYTHING &lt;
Sep 30 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, moishy.

Since '&lt;' and '&gt;' do not contain any reserved characters, you can do something like this:
Expand|Select|Wrap|Line Numbers
  1. /(?<=^|&amp;gt;).+?(?=$|&amp;lt;)/
  2.  
Which will match any text in between (the start of the string or '&gt;') and (the end of the string or '&lt;').

For more information on using regular expressions, check out this site.
Sep 30 '07 #4

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

Similar topics

5
8263
by: sinister | last post by:
The examples in the online manual all seem to use double quotes, e.g. at http://us3.php.net/preg_replace Why? (The behavior is different with single quotes, and presumably simpler to understand.)
4
1401
by: TekWiz | last post by:
I'm using regex to validate data, but preg_match gives the Warning "Unknown modifier '\' " when I have '\\' in the regular expression. Is this a problem with preg_match() or do I have to do something different with regex? Note: I ran my expression through "The Regex Coach" by Dr. Weitz and it worked properly. --TekWiz
2
1545
by: Juggernaut | last post by:
Hi I was trying to write a script to replace some text inside some tags. Lets say I had <tag stuff=stuff><tag stuff=otherstuff><another> I wanted it to find all the <tag and remove them. So I tried to write it so that it would go forward until it reached came. But when I tried that it would respond to another as single characters and not as the word.
2
3993
by: toedipper | last post by:
Hello, The following bit of code does a preg match and does something if true (sets $browser to ppcie) Without using if then and else's how do I code it so it does not equal what it is testing for? So if it does not find ppc in the $agent then it does something else/sets it to something else? $agent = getenv("HTTP_USER_AGENT");
4
1997
by: system7designs | last post by:
I don't know preg's that well, can anyone tell me how to write a regular expression that will select everything BUT files/folders that begin with ._ or __?(that's period-underscore and underscore underscore)
14
2023
by: frizzle | last post by:
Hi group, I have a function which validates a string using preg match. A part looks like if( !preg_match( '/^(+((*)?)?)$/', $string ) || preg_match( '/(--|__)+/' ,$string) ) { i wonder how i could combine those two into one ...
1
1966
by: terence.parker | last post by:
I am trying to do a search through some data, more specifically HTML, to extract data from it. So for example I may have: <b>Title:</b<em>This is a title</em> <b>Name:</b<em>Fred</em> I wish to grab the data "This is a title" and "Fred" against their corresponding headings in an array (e.g. $array = "This is a title") .... but the key doesn't matter, that need not come from the regexp but I can do manually.
5
1396
by: monomaniac21 | last post by:
hi all what is the preg for capitals in a word to be replaced by that word preceded by a space? i need to be able to do this in preg: thisWord := this Word AnotherExample := Another Example
2
4257
by: JanDoggen | last post by:
function vldLicense($lic) { echo "called with lic: ". $lic . "<br>"; echo preg_match('', $lic) . "<br>"; if (preg_match('{4}-{4}-{4}-{4}', $lic) == 0) return false; return true; } gives me:
0
10268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10031
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.