BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-19-2012, 06:30 AM   #1 (permalink)
New Member
 
Join Date: Feb 2012
Model: 9160
PIN: N/A
Carrier: vodacom
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Post How do I replace more than 1 character in blackberry?

Please Login to Remove!

Hi,

I know how to replace a certain character with another character in a string:


System.out.println(replaceAll("Where are you??", "?", "")
public static String replaceAll(String front, String pattern, String back){

if (front == null)
return "";

StringBuffer sb = new StringBuffer(); //A StringBuffer is created
int idx = -1;
int patIdx = 0;

while ((idx = front.indexOf(pattern, patIdx)) != -1)
{
sb.append(front.substring(patIdx, idx));
sb.append(back);
patIdx = idx + pattern.length();
}

sb.append(front.substring(patIdx));
return sb.toString();
}

This code will replace all ? with an empty space and would print out ("Where are you")

Now what I want to know is how can I replace more than 1 character. In Java I can just use simple regex, but if in blackberry I write something like:

System.out.println(replaceAll("Henry!! Where are you??", "!?", "")

then blackberry doesn't pick it up. So how do I overcome this limitation that blackberry has?
Offline  
Old 07-23-2012, 01:11 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: How do I replace more than 1 character in blackberry?

You will probably have to invent this by using StringMatch and then replacing the data matched.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: How do I replace more than 1 character in blackberry?
Thread Thread Starter Forum Replies Last Post
HOWTO: Use BlackBerry on Generic NON-BlackBerry Data Plan Mark Rejhon BlackBerry Network 92 03-08-2014 12:26 PM
Bes 4.1.7 Mr2 Mikey_AGBoston BES Admin Corner 5 04-29-2010 02:37 PM
Perform a cutover to another BlackBerry Enterprise Server in IBM Lotus Domino hdawg BES Admin Corner 3 04-25-2008 09:47 AM
New Blackberry Server wants to reactivate users after power outage! Urlryn BES Admin Corner 19 12-27-2007 03:55 PM
First post thought I'd make it helpful mazzel General 8100 Series Discussion - Pearl 1 05-30-2007 03:45 PM

(1PCS) STIL04-P5 IC AC CURR LIMITR PENTAWATT5 HV2 STIL04 04-P
$1.97
(1PCS) STIL04-P5 IC AC CURR LIMITR PENTAWATT5 HV2 STIL04 04-P picture(1PCS) LCP1511DRL SUPPRESSOR VOLT DUAL LINE 8-SOIC 1511 LCP1511
$1.82
(1PCS) LCP1511DRL SUPPRESSOR VOLT DUAL LINE 8-SOIC 1511 LCP1511 picture(1PCS) LCP02-150B1 SURGE SUPPRES IC FOR SLICS 8SOIC LCP02 02-150
$3.02
(1PCS) LCP02-150B1 SURGE SUPPRES IC FOR SLICS 8SOIC LCP02 02-150 picture(1PCS) TLP200G-1 IC OVP TRIPOLAR TELECOM I2PAK 200 TLP200
$2.74
(1PCS) TLP200G-1 IC OVP TRIPOLAR TELECOM I2PAK 200 TLP200 picture(5PCS) ACS102-6TA-TR IC AC SWITCH .2A 600V TO-92 102 ACS102
$5.98
(5PCS) ACS102-6TA-TR IC AC SWITCH .2A 600V TO-92 102 ACS102 picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.