I Love Bonnie.net http://www.ilovebonnie.net Love, Life & Technology in a Turbulent World Fri, 16 May 2008 05:12:50 +0000 http://wordpress.org/?v=2.5.1 en Ponce de Leon High School Ordered to Notify Students that Standing Up for Gay Rights is Okay http://www.ilovebonnie.net/2008/05/15/ponce-de-leon-high-school-ordered-to-notify-students-that-standing-up-for-gay-rights-is-okay/ http://www.ilovebonnie.net/2008/05/15/ponce-de-leon-high-school-ordered-to-notify-students-that-standing-up-for-gay-rights-is-okay/#comments Fri, 16 May 2008 05:05:23 +0000 admin http://www.ilovebonnie.net/?p=44 In Februay I wrote about a story involving Heather Gillman and Ponce de Leon high school. The student was suspended for standing up for gay rights within her school. As a result, the writer of this blog has received numerous threats in regards to the story. The ACLU was put into the mix and now, 3 months later, the courts have ordered the school to notify students, in writing, that standing up for gay rights is okay.

The principal, David Davis, suspended the student in question and was quoted as telling a person to “not be gay.”

Unfortunately, the principal has learned nothing from the experience. According to WJHG news, the principal:

“…would not go on camera. He did say he’s disappointed in the judges’ decision, but he will abide by that ruling.

According to the Miami Herald:

“Davis also testified that he believed rainbows were “sexually suggestive” and would make students unable to study because they’d be picturing gay sex acts in their mind. The principal went on to admit that while censoring rainbows and gay pride messages he allowed students to wear other symbols many find controversial, such as the Confederate flag.”

It is disgusting to think that the principal of a school would equate a gay rights symbol to a symbol associated with slavery and stupidity. However, it sheds light on where his ignorant beliefs may stem from.

I am glad that the school is being taught a lesson and I hope the people in the community of the school will stand together to remove this ignorant and terrible person from the Ponce de Leon school administration.

]]>
http://www.ilovebonnie.net/2008/05/15/ponce-de-leon-high-school-ordered-to-notify-students-that-standing-up-for-gay-rights-is-okay/feed/
HP Pavilion DV6000 Laptop Wireless Failure - HP Says 1 in 7 Affected http://www.ilovebonnie.net/2008/05/10/hp-pavilion-dv6000-laptop-wireless-failure-hp-says-1-in-7-affected/ http://www.ilovebonnie.net/2008/05/10/hp-pavilion-dv6000-laptop-wireless-failure-hp-says-1-in-7-affected/#comments Sun, 11 May 2008 03:06:05 +0000 admin http://www.ilovebonnie.net/?p=42 If your wireless is failing for no reason on your HP Pavilion DV6000 laptop, call HP before your warranty runs out. An HP tech admitted that 1 in 7 of them require motherboard replacement to fix the problem. Not a BIOS upgrade or drivers.

You should call HP to get your laptop serviced if your laptop is exhibiting the following behavior

  • Wireless device no longer recognized
  • Wireless switch doesn’t work
  • Wireless will not come back after shutting down or going into a sleep mode

The HP Pavilion DV6000 is a fairly popular laptop. Available at many retail outlets and online, it happens to be the one that I decided to purchase just under a year ago.

It’s a decent machine and the price was right. My particular model is a DV6436nr that I picked up at Best Buy. After removing Vista and installing Ubuntu, the laptop was running rather well. However, the wireless was spotty at best.

I assumed that it was due to the difficulties that can occur with wireless and Linux. I followed all of the guides and installed all the drivers. Yet for some reason, my wireless just seemed to be getting worse. Eventually, the device would only work when it felt like it. I decided to go ahead and install Windows XP and see if I could get it working in that OS. No dice. My laptop was still within warranty so I decided to start looking around to see if anyone else was having this problem.

It wasn’t long before I came across this lengthy thread at the HP site. In it, “Anna” from HP says that updating the BIOS will fix the problem:

“Hi, it’s Anna from HP Total Care,

I’m sorry some of you are having trouble with your wireless WLAN not detecting your wireless network and not displaying in your device manager. The issue appears to be affecting AMD based Dv6000, v6000 and Dv9000 notebooks running Microsoft Windows Vista.

We’ve got a BIOS update and some instructions on getting this resolved. If the BIOS update does not resolve the issue, please contact HP support and we will help facilitate a repair.

Please do not try replacing your wireless card or inserting a third party wireless modules as some have suggested here on this forum. This will not resolve the issue and is in violation of FCC regulations.

[...Instructions on how to install the BIOS update...]

I hope this is helpful. Please let me know if you have any further questions and we’ll work to respond personally or on the forum as best we can.

Anna”

This solution was garbage and yielded no results. The switch on the front was basically useless and the device simply was not being recognized any longer. Frustrated, I searched further and found that this is a much more prevalent problem than I originally thought. Even ZDNet posted an article about the failure.

I eventually called HP to get my laptop repaired. As indicated in other posts, the solution is a motherboard replacement.

Here’s the kicker: the customer service agent who helped me when I called HP said:

“Yea, there’s about 1 in 7 laptops that are affected. But, there’s no way to tell which ones they are and that’s not enough to do a recall.”

Wow. The worst part is: the problem is hard to diagnose due to the fact that the device only works half the time. Instead of it being a problem with the wireless, or the drivers, or the BIOS, it’s a problem with the motherboard.

I’ll admit: the repair process was painless. They sent me a box overnight with shipping labels and I had my laptop back in a week or so. But come on HP: if 1 in 7 devices are failing and it’s hard to detect, help the consumer out and let them know.

Until then however, you can call HP at 800-474-6836.

]]>
http://www.ilovebonnie.net/2008/05/10/hp-pavilion-dv6000-laptop-wireless-failure-hp-says-1-in-7-affected/feed/
Javascript - Removing All Select (Drop-Down) Elements from a Page http://www.ilovebonnie.net/2008/05/05/javascript-removing-all-select-drop-down-elements-from-a-page/ http://www.ilovebonnie.net/2008/05/05/javascript-removing-all-select-drop-down-elements-from-a-page/#comments Mon, 05 May 2008 20:35:01 +0000 admin http://www.ilovebonnie.net/?p=41 The greybox effect that we use for our images in the project that I was working on had a small flaw. Unfortunately, in IE6 (go figure), drop-down menus were showing through whenever a user had expanded the image on the screen.

This was obviously not desirable.

I couldn’t find exactly what I was looking for on the net so I decided to share my snippet of code with everyone out there in case another person was trying to achieve this (or a similar) effect.

Our code uses a toggle for the grey box stuff so we had to make sure one check would be able to take care of all of the select menus on the page:

var dropDowns = document.getElementsByTagName('select');
for (var ii = 0; ii < dropDowns.length; ii++)
{
    if (dropDowns[ii].style.display == 'none')
    {
        dropDowns[ii].style.display = '';
    }
    else
    {
        dropDowns[ii].style.display = 'none';
    }
}

This could be used for any type of tag so hopefully others will be able to use this.

Enjoy!

]]>
http://www.ilovebonnie.net/2008/05/05/javascript-removing-all-select-drop-down-elements-from-a-page/feed/
Albert Hofmann, Inventor of LSD - Dead at 102 http://www.ilovebonnie.net/2008/04/29/albert-hofmann-inventor-of-lsd-dead-at-102/ http://www.ilovebonnie.net/2008/04/29/albert-hofmann-inventor-of-lsd-dead-at-102/#comments Tue, 29 Apr 2008 17:19:57 +0000 admin http://www.ilovebonnie.net/?p=40 [UPDATE] - It has been confirmed. The email from Rick Doblin (head of MAPS) has been published here. In addition, Erowid has updated their site here. Here’s the contents of the message from Mr. Doblin:

“Albert died at home at 9 AM Basel time from a myocardial infarction, quick and relatively painless. Two caretakers were there with him at the time. The only people who were told were people from Burg, the village where he lived, and Peter and others were surprised the word of his death had gotten out so quickly. It’s the age of the internet…

Albert had been increasingly thinking of death these last few months. He had stopped leaving his home, where he said he could feel the spirit of Anita, his wife who died December 20, 2007. He didn’t come to the World Psychedelic Forum a month ago, but did entertain some visitors at his home. We spoke on the phone the day after the Basel conference and he was happy and fulfilled. He’d seen the renewal of LSD psychotherapy research with his own eyes, as had Anita. I said that I looked forward to discussing the results of the study with him in about a year and a half and he laughed and said he’d try to help the research however he could, either from this side or “the other side”.”

[UPDATE] - A comment left in an article on boingboing about the subject states that confirmation has been obtained from Rick Doblin, head of the Multidisciplinary Association for Psychedelic Studies (MAPS)

According to a post made by a reddit.com contributor named t4inted:

Albert Hofmann, the father of LSD, passed away last night.

Here is the quote:

“This isn’t in the news yet. I’m from Basel and Hoffmann lived close (in Burg). My friends mother helped to look after him, he died last night (of old age probably, he was 102).

You might not belive one source you don’t know and who has no way to back up his claims but it’s true. It will probably go public soon.”

I hope that I get to update this page later and say it was a hoax.

But if it is true, then we can only hope that he is dancing and happy.

Thanks Mr. Hofmann. You changed human kind forever.

]]>
http://www.ilovebonnie.net/2008/04/29/albert-hofmann-inventor-of-lsd-dead-at-102/feed/
Shots Fired in Iran Send Oil Prices Up Just in Time for Stimulus Packages http://www.ilovebonnie.net/2008/04/25/shots-fired-in-iran-send-oil-prices-up-just-in-time-for-stimulus-packages/ http://www.ilovebonnie.net/2008/04/25/shots-fired-in-iran-send-oil-prices-up-just-in-time-for-stimulus-packages/#comments Fri, 25 Apr 2008 17:10:07 +0000 admin http://www.ilovebonnie.net/?p=39 News sources are oozing today with the news that a cargo ship contracted by the U.S Military Sealift Command (source) fired shots upon Iranian vessels.

Apparently there were warnings to the boats that they were getting too close. Then, according to Cmdr. Lydia Robertson, a spokeswoman for the U.S. Navy’s Bahrain-based Fifth Fleet, there were bursts of machine-gun fire and rifle warning shots. All of this occurring just 50 miles off the coast. Cmdr. Robertson then added:

“The small boats left the area a short time later. They were able to avoid a serious incident by following the procedures that we use.”

A serious incident? Sheesh. (source).

Because of this incident, there has been a $3 per barrel increase in the price of oil. However, Iranian navy sources in Tehran have denied that the incident even occurred. It’s hard to imagine that an increase in oil prices would miraculously occur after an event which didn’t happen.

Not to worry folks! Nothing to see here! The mainstream media, not always wanting to be the bearers of bad news, decided that the most important news for this week is the stimulus package rebates that (apparently) started going out on Monday.

U.S. CONTRACTED VESSELS ARE FIRING BURSTS OF MACHINE GUN FIRE AT IRANIAN VESSELS

STIMULUS PACKAGE
$$$$$$$$$$$

There goes the neighborhood.

]]>
http://www.ilovebonnie.net/2008/04/25/shots-fired-in-iran-send-oil-prices-up-just-in-time-for-stimulus-packages/feed/
Finally - Firebug and Tab Mix Plus for Firefox Beta http://www.ilovebonnie.net/2008/04/22/finally-firebug-and-tab-mix-plus-for-firefox-beta/ http://www.ilovebonnie.net/2008/04/22/finally-firebug-and-tab-mix-plus-for-firefox-beta/#comments Tue, 22 Apr 2008 17:28:45 +0000 admin http://www.ilovebonnie.net/?p=38 As many of you probably know by now… Firefox 3 is great. However, it is still in Beta.

For those of us web developers, one of the woes of the beta was the loss of our beloved Firebug. This add-on makes designing and customizing web pages a snap. Chances are, that if you are an avid surfer or a web developer, you are also reliant on the wonderful Firefox plugin Tab Mix Plus. It allows you to customize how you want your tabs displayed and (perhaps most importantly) allows you to split your tabs into rows.

Until recently, you had to alter the add-ons a bit in order to get them to work with Firefox beta 5.

However, now you can grab the newest versions of these add-ons and they work like a charm! Keep in mind that they (like Firefox 3 Beta) are versions in development so use them at your own risk! (I just had to put that in there but they seem to work fine for me)

Here are the links:

Now you can use your favorite new beta Firefox browser with your favorite add-ons again!

I hope someone else finds these links helpful. Long live Firefox 3!

]]>
http://www.ilovebonnie.net/2008/04/22/finally-firebug-and-tab-mix-plus-for-firefox-beta/feed/
PacSun Customer Services Goes From Horrible to Helpful in 24 Hours http://www.ilovebonnie.net/2008/04/15/pacsun-customer-services-goes-from-horrible-to-helpful-in-24-hours/ http://www.ilovebonnie.net/2008/04/15/pacsun-customer-services-goes-from-horrible-to-helpful-in-24-hours/#comments Tue, 15 Apr 2008 18:38:43 +0000 admin http://www.ilovebonnie.net/?p=37 If you are looking for the unlisted phone number to report a complaint about an in-store experience with PacSun, please scroll to the end of this post.

This particular experience began in early March of 2008. I was in need of a new belt as mine had become tattered and worn after about a year of use. I decided that since this belt had held on pretty well, that I would go purchase another belt from the same vendor.

The store in this case is PacSun located in Missoula, Montana in Southgate Mall. I had gone to the store many times before and even knew a person who worked there.

Let me start by saying that I have been a patron to this store since it started in the early nineties. Mostly because the Bullhead brand of jeans that they sell fit me better than jeans I can get elsewhere. In fact, I remember when it was still called Pacific Sunwear.

I went in and purchased a black spiked belt not unlike this one:

Keep in mind, I do web application development for a living so I am not constantly engaged in activities which would cause an abnormal amount of wear upon a belt. However, after only a month of owning the product, it snapped completely in half while putting it on one morning. So Bonnie and I went back to the store with the intentions of receiving a refund for such an obviously shoddy product.

We walked into the store and a younger gentleman behind the counter asked if he could help us. We explained that we would like to return a belt and held up the broken product. He said he would grab someone else to help us. A small, female employee approached us and asked us what was up. We explained to her that we had purchased the belt just a month ago and already it broke completely in half. Then she said to hold on while she went to the back. At this point, the gentleman piped up and jokingly said: “Don’t worry, we’ll find someone who know what they’re doing.”

After a minute or two the employee emerged from the back and went to back to the counter and started going through a notebook. While she was looking for something (she didn’t tell us what she was doing), she was able to find the time to help another employee looking for what appeared to be a display guide. After a few more minutes of just standing there, she said that they could give us a new belt or give us store credit. I plainly said that I didn’t want to replace the belt with another one because I was worried it would also break. She stated that it was company policy. “If it broke after a couple of days, then I wouldn’t mind,” she said. “You can trade this (holding up the belt) for a brand new one or get store credit.”

I then asked, “What do I do if the next belt breaks on me again then?” This received no response and an odd look. She then pointed to the bit of wear that had started to occur around the buckle of the belt and said, “This is obviously really worn down.” Of course, the belt snapped in half in the middle of the belt, not near any worn areas. Then the male employee said, “Yea, I’ve got belts that are 4 years old that don’t have that much wear on them.” I responded with, “So, what: I’m wearing my belt wrong? Is that what you’re trying to tell me?” He giggled. I wanted to smack the silly haircut off of his head.

At this point the female employee was getting agitated and said “Look you can take the new belt or get store credit. That’s company policy.” My fiancee then referred to the return policies listed on a small sign on the front of the counter saying “There’s nothing on this sign that says it’s store policy to not refund obviously defective items.” The response? “Well, I know it’s not listed there, but that’s how it is.”

At this point it was obvious that none of the employees helping us had any idea what customer service was so I asked if there was some kind of corporate number available. She responded flippantly with: “I’ll see what I can find.” She indicated towards the receipt (which both Bonnie and I interpreted as: “It’s on the recepit.”), placed the stuff in a bag and handed it to us. Upon leaving the store, there was no number on the paper given to us and we had a store credit for a product that was obviously faulty.

The next morning, I decided to look for a number on the internet to call and report this behavior. Guess what? PacSun does not list their number for in store customer service complaints ANYWHERE on their site or (after a Google search) on the internet. I decided to call the website phone number. When I spoke with someone on the phone, they indicated that they could not help me and gave me the number to call. He then added, “You’re going to have to leave a message and then someone will call you back within 48 hours.”

WHAT?! You mean to tell me that customers, who are irate because of an in-store experience, have to call a number (if they can find it) and leave a message with the hope that someone will call them back? That’s probably the worst consumer customer complaint handling that I have ever heard of.

So he connected me, I left a message, and assumed I wouldn’t hear anything for quite a while.

Shortly after I returning home from work, I received a call asking for me by my first name. The woman on the phone then asked me to tell my story of the PacSun experience to her. After listening to my story, she informed me that the staff on that day was full of inexperienced people who had been there for less than 4 months. She apologized profusely and said that she would be talking to the store manager about scheduling a better mix of experienced and inexperienced people. She offered me a coupon for $25.00 off a $50.00 purchase with no expiration date and said that we would be able to use our gift card in conjunction with the coupon because of the terrible experience. She then gathered my information and apologized some more.

The woman on the phone (Cindy B. - District Manager) was extremely helpful, very kind and honest about the situation. That was all I was looking for from the store employees. They should have acknowledged the product was faulty, refunded the money, and been far more helpful for a customer who was obviously in a distressed situation.

When all was said and done: the experience with the district manager helped to save an otherwise horrible interaction in the store and I will probably go back there to buy more jeans. However, I will definitely not be buying a belt from them any time soon.

[UPDATE]: Cindy B. went above and beyond with the package that I received. It was shipped 2-day mail and included a hand-written apology note and two Bullhead brand t-shirts along with the promised $25 off card. Now that’s what I call customer service.

By the way: here is the COMPLETELY UNLISTED phone number for reporting a bad in store experience with PacSun:

1-800-444-6770 - extension 5030

Also, I asked Cindy B. about the fact that in-store complaints are handled through voicemail. Apparently, there is one person who checks the voicemail and then disperses it to the proper channels. Just a suggestion PacSun? Let pissed off customers talk to someone on the phone. Don’t make them leave a message.

If you liked this post, then please be sure to subscribe to my feed.

]]>
http://www.ilovebonnie.net/2008/04/15/pacsun-customer-services-goes-from-horrible-to-helpful-in-24-hours/feed/
Sam Zell and Rupert Murdoch Appointed to the Associated Press Board of Directors http://www.ilovebonnie.net/2008/04/14/sam-zell-and-rupert-murdoch-appointed-to-the-associated-press-board-of-directors/ http://www.ilovebonnie.net/2008/04/14/sam-zell-and-rupert-murdoch-appointed-to-the-associated-press-board-of-directors/#comments Mon, 14 Apr 2008 21:10:31 +0000 admin http://www.ilovebonnie.net/?p=36 Just when you thought the mainstream media couldn’t get more convoluted and controlled, on April 14th, 2008, the Associated Press announced their new members for their board of directors.

The Associated Press is the last remaining nationally oriented news service in the United States. It is a service that can reproduce stories that are published with American news organizations that belong to the organization. Companies can then pay a fee to the Associated Press to reproduce the story in other countries/languages.

However, the latest appointees to the board of directors definitely points to a bid for control and power.

Here are the 4 new members:

Just look at the massive amount of media these companies control.

In a world where the major news media outlets are falling to the online availability and dispersal of information that comes with the internet, it is not surprising that the heads of these news outlets are coming together to decide what and how news is delivered to the rest of the world. However, I don’t think I’m the only one who thinks that none of these appointees are there for our interests in any way, shape, or form.

For more information and the original story, check out this link.

If you liked this post, then please be sure to subscribe to my feed.

]]>
http://www.ilovebonnie.net/2008/04/14/sam-zell-and-rupert-murdoch-appointed-to-the-associated-press-board-of-directors/feed/
PHP and Regex - Replacing Repeating Characters with Single Characters in a String http://www.ilovebonnie.net/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/ http://www.ilovebonnie.net/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/#comments Thu, 10 Apr 2008 19:38:54 +0000 admin http://www.ilovebonnie.net/?p=35 [Update] - a comment left by TLP gives a much better solution to the problem that seems to be better in benchmarks as well. I’m changing the post to reflect the best and fastest method for the situation described.

In a previous post, I described a situation where we needed to remove a repeating dot in a user name. In this article, I mentioned the first site that came up when searching in Google to find a solution.

I thought that I might have come across something that would be a solution for what this person was looking for. However, they clarified what they needed the function to do on their website and left me a comment with some more info:

“Thanks for citing us but the article was about making a unique chars string. For example: “aabbccaaaaaddee” will become “abcade“. That is what I accomplished in the article. I know very well regular expression and there are some way of accomplishing that but not in one step. Every char of the string must be separated by a separator (ex: comma, pipe, etc) and then apply the lookback regular expression.

The beauty of using regular expressions is this: a lot of steps that are needed to accomplish some string formating/parsing can be done in one step using RegExp. But if there are the same amount of steps it will be faster not to use RegExp.”

I love programming and I definitely love a challenge and so, webdev.andrei: I accept your challenge.

$str = ‘aabbccaaaaaddee’;
echo preg_replace(’{(.)\1+}’,’$1′,$str);
//abcade

This type of simple expression is thanks to a commenter that dropped by named TLP. We’ll try break it down to see how it works. The curly braces {(.)\1+} without a number in the middle means to repeat it as many times as needed until it no longer occurs. The round brackets {(.)\1+} create something called a backreference. A backreference allows it to reuse part of the regular expression match in the expression itself. So, when it comes to the first character repeating more than once, it will replace it with a single version of itself (or $1). It then places itself back in at the location of the backslash-1 {(.)\1+}.

Throughout the night until the wee hours of the morning I was furthering my ‘regex-fu’. I ultimately came to a simple loop that seems to satisfy the issue.

$string = ‘aabbccaaaaaddee’;
$new_string = ”;
$starting_char = 0;
while (strlen($string) > 0 && $starting_char < strlen($string))
{
    $blah = preg_match('/[A-z]{2,}/', $string, $matches);
    $letter = $matches[0][$starting_char];
    $new_string .= $letter;
    $regex = '/' . $letter . '{2,}/';
    $string = preg_replace($regex, $letter, $string);
    $starting_char++;
}
echo $new_string;

In short: it tries to find a repeating character. When it finds one, it replaces it with a single version of itself. Now that it knows the first repeating instance is now a single character in the string, it can move on to the next character of the string and try that one out. It does this until there are only single instances of each character left in the string.

And there you have it. This could be done with any number of different characters by altering the first line of the loop and inputting a different range of characters instead of [A-z].

I hope this helps others and especially hope that webdev.andrei can get some use out of it.

If you liked this post, then please be sure to subscribe to my feed.

]]>
http://www.ilovebonnie.net/2008/04/10/php-and-regex-replacing-repeating-characters-with-single-characters-in-a-string/feed/
PHP and Regex - How to Replace or Remove a Repeating Character http://www.ilovebonnie.net/2008/04/09/php-and-regex-how-to-replace-or-remove-a-repeating-character/ http://www.ilovebonnie.net/2008/04/09/php-and-regex-how-to-replace-or-remove-a-repeating-character/#comments Wed, 09 Apr 2008 20:22:31 +0000 admin http://www.ilovebonnie.net/2008/04/09/php-and-regex-how-to-replace-or-remove-a-repeating-character/ While at work I came to an interesting conundrum when trying to validate/clean user names for the application I work on. Here is a description of the restrictions we put on our user names:

“ID may consists of A-Z, a-z, 0-9, underscores, and a single dot (.).”

While the project development staff is extremely talented, we didn’t have anyone who was particularly amazing with regular expressions. I decided to go ahead and take the plunge and start to do some research into the subject. I took a look around the internet and within the PHP documentation and couldn’t find an example of exactly what I was looking for. In fact, while searching for “php remove repeating character in string,” the first article listed in Google included a note at the bottom stating:

“I tried to have the same result using regular expressions but no success. If anyone resolved this using RegExp please share :).”

It was evident I was going to dive into the wonderful world of regex on my own. Our other filtering functions were easy enough. We have ranges of acceptable characters and some RFC-type reg-ex checks on many of our inputs that we let our users submit. In most cases running through something like this:

cFilter::clean_variable($variable);

This would run a preg_replace with the necessary regex expression and remove the bad stuff.

The challenging part was enforcing the single character. Here’s why. Let’s assume that someone wants to enter the user name of ‘cool…guy‘. First note: I am escaping the ‘.’ character with a backslash (’\').

$nickname = ‘cool…guy’;
if (ereg(”\.{2,n}”, $nickname, $reg))
{
    echo var_dump($reg);
}

This code produces the following output:

array(1) { [0]=> string(3) “…” }

So, if we were to run a replace using the simple “\.{2,n}”, we would end up blowing away all the dots. But that’s not what we’re looking for because the user is allowed to have one dot in their name. So, simply replacing the offending area with black characters was not going to work.

The second iteration I came up with was the following:

while (ereg(”\.{2,}”, $string, $reg))
{
    $string = str_replace($reg[0], “.”, $string);
}

If you are familiar with PHP, you can probably see that I am using ereg with str_replace. So, why not just use ereg_replace? Well, that’d be a great plan. Here’s what I finally came up with:

$new_string = ereg_replace(”\.{2,}”, “.”, $string);

So, if you wanted to use a different character, here’s an example of what you can do with this line of thinking. In this case, we want them to be able to have an ‘n’ in their name, but only one:

$string = ‘coolnness’;
$new_string = eregi_replace(”n{2,}”, “n”, $string);
echo $new_string;

If you wanted to remove the offending characters all together, then use a blank character identifier in place of the second parameter like so:

$new_string = eregi_replace(”n{2,}”, “”, $string);

Hope this helps someone else ’cause it sure took me a while to figure out. If you liked this post, please be sure to subscribe to my feed.

]]>
http://www.ilovebonnie.net/2008/04/09/php-and-regex-how-to-replace-or-remove-a-repeating-character/feed/