简体   繁体   中英

String to text field in android app

I have the following data scanned from a pdf417 and need to extract certain text to certain text fields (already created), not sure how to go about this... Data scanned with manatee works plugin and android app using android studio.

All help will be appreciated.

Data that was returned from scan - %MVL1CC18%0154%4025M003%4025012RP01C%DC62XBGP%NISSAN%SILVER/SILWER%

Each part between the %'s need to go to a text field. I know that I need to make use of String substr=mysourcestring.substring(startIndex,endIndex); but this will work up to the first 2 % signs. How do I continue to the next few?

Thanks.

If you want to split string based on a delimiter, use the following

String delimitter="%";
String[] parts = inputString.split(delimitter);

Why not use String.split() ?

In your case it would look something like this:

String[] extractedStrings = mysourcestring.split("%");

You can work on your string by using split method:

String yourString = "%MVL1CC18%0154%4025M003%4025012RP01C%DC62XBGP%NISSAN%SILVER/SILWER%";
String[] split = yourString.split("%");

In this way you will get an array where each item is a substring between two % chars.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM