BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 07-19-2012, 06:30 AM   #1
Lukaszz
New Member
 
Join Date: Feb 2012
Model: 9160
PIN: N/A
Carrier: vodacom
Posts: 4
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
Dougsg38p
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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 95 05-20-2018 07:58 AM
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


Siemens JXD63B250H 250amp 600volt 3 Pole Circuit breakers picture

Siemens JXD63B250H 250amp 600volt 3 Pole Circuit breakers

$270.00



10 x  SIEMENS QA120AFCN PLUG ON NEUTRAL 20A AFCI ARC FAULT BREAKERS NEW picture

10 x SIEMENS QA120AFCN PLUG ON NEUTRAL 20A AFCI ARC FAULT BREAKERS NEW

$328.99



🔥10 PCS SIEMENS Q120DFN 20A DUAL AFCI/GFCI PLUG ON NEUTRAL BREAKER BRAND NEW🔥 picture

🔥10 PCS SIEMENS Q120DFN 20A DUAL AFCI/GFCI PLUG ON NEUTRAL BREAKER BRAND NEW🔥

$449.00



NEW Siemens 6GK5008-0BA10-1AB2 6GK5 008-0BA10-1AB2 Industrial Ethernet Switch picture

NEW Siemens 6GK5008-0BA10-1AB2 6GK5 008-0BA10-1AB2 Industrial Ethernet Switch

$132.90



Box of 10 New Siemens QA115AFCN 1p 15 amp 120v Plug In Combo Arc Fault Breaker picture

Box of 10 New Siemens QA115AFCN 1p 15 amp 120v Plug In Combo Arc Fault Breaker

$324.99



1PCS Unopened New Siemens board 6SE7033-5HH84-1HH0 6SE7 033-5HH84-1HH0 picture

1PCS Unopened New Siemens board 6SE7033-5HH84-1HH0 6SE7 033-5HH84-1HH0

$266.41







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