If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Enjoy an ad free experience by logging in. Not a member yet? Register.

The * is known as a quantifier (which says any number of occurrences). There are other quantifiers:
+ which says one or more occurrences
? which says zero or one occurrences
{n} which says exactly n occurrences
{n,m} which says from n to m, inclusive, occurrences

The * and + quantifiers are greedy, in that they match the maximum number of occurrences that satisfy the regular expression (i.e. your expression (.*) included anything between and including other 's and 's). To make it non-greedy, you can use the ? after the * or + because the ? says zero or one occurrences. This means that it will match the least number of occurrences that satisfy the regular expression.

dmittner >>
Your code worked fine - (of course, you need to initialize the $newchar variable to something first or it will just delete all the i's) like: $newchar = a; will replace all the i's with a's between the opening and closing bold tags. Or you could simply 'hard-code' it like: $1a$2