473,322 Members | 1,755 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,322 software developers and data experts.

Regular Expression: What is the wrong with this code ?

abdoelmasry
104 100+
What is the wrong with this code ?

it always returns zero matches.

I think it should return two matches,

I need to read how may tags like this pattern

Expand|Select|Wrap|Line Numbers
  1. <!== any thing ==!>
Expand|Select|Wrap|Line Numbers
  1. $string = "<!==Abdo==!><!==Ahmed==!>";
  2. print_r(preg_match_all("/<\!==*==\!>/", $string));
if anybody can help.

Thank you
Dec 31 '13 #1
2 1148
Rabbit
12,516 Expert Mod 8TB
The asterisk (*) character tells it to take the preceding character/group and look for 0 to infinite matches. So in this case, you are saying you want 0 to infinite equal sign symbols (=). Asterisk does not mean any number of character.

The expression you want is <!==[^<]*==!>. What you want is for it to match any number of characters that is not a less than symbol (<). Therefore, [^<] matches a character that is not a less than symbol. And the asterisk after it tells it to match any number of characters that is not a less than symbol.
Dec 31 '13 #2
abdoelmasry
104 100+
Thank you Pro Very good (y)
Jan 1 '14 #3

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

Similar topics

3
by: Tom | last post by:
I have struggled with the issue of whether or not to use Regular Expressions for a long time now, and after implementing many text manipulating solutions both ways, I've found that writing...
0
by: Dave | last post by:
I am trying to return a regular expression from code behind to server control in aspx page. Problem is regularexpressionvalidator tag interprets string incorrectly. // aspx...
10
by: Lee Kuhn | last post by:
I am trying the create a regular expression that will essentially match characters in the middle of a fixed-length string. The string may be any characters, but will always be the same length. In...
5
by: Matt | last post by:
I have a problem and I am looking for suggestions. Here is the situation: I am writing a VB.NET app to convert a string into a markup language used in a program we have at my company. The...
1
by: Don | last post by:
I've created a regular expression to match everything from the word "const" to the end of the last line that doesn't end in a space-underscore characters. i.e. ...
25
by: Mike | last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in matches. I would like to get what the actual regular expression is. In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
6
by: sk.rasheedfarhan | last post by:
Hi , I am using regular expression in C++ code, . Negation is not working in the down loaded code. matches all characters except "a", "b", and "c] So I am in dilemma can negation work in C++...
6
by: rorymo | last post by:
I have a regular expression that allows only certain characters to be valid in an xml doc as follows: <xs:pattern value="^*" /> What I want to do is also allow any unicode character that is...
2
by: Joey | last post by:
Hello guys, I'm trying to learn about regular expressions. I need to be able to use an RE that can evaluate for STRINGS (or specific sequences of characters), not just occurances of characters....
1
by: NvrBst | last post by:
I want to use the .replace() method with the regular expression /^ %VAR % =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)" regular expression with "":...
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: 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: 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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.