Splitting a japanese sentense using colon
[B]i want to split a japanese sentense using colon.. i can split a sentense which is having english before colon and japanese after that example (hello how are u :芝ダイレクト Yahoo!店") .. i can spliut this but i could not be able to split the below sentense .
|||||||||||[PR]3日前にストアがつぶやきましたレビュー:1件評価:-ストア:東芝ダイレクト Yahoo!店"
can any one help me to do this please .. this is the program i have tried
import java.io.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.regex.Pattern;
public class SplitString {
public static void main(String args[]) {
try {
String str = "|||||||||||[PR]3日前にストアがつぶやきましたレビュー:1件評価:-ストア:東芝ダイレクト Yahoo!店";
String[] a, b;
str = URLEncoder.encode(str, "UTF-8");
a = str.split(":");
//System.out.println(str);
//System.out.println(URLEncoder.encode(":", "UTF-8"));
// System.out.println(a[1]);
for (int i = 0; i < a.length; i++) {
System.out.println(URLDecoder.decode(a[i], "UTF-8"));
// if(a[i].contains("//:")){
// System.out.println("SPLIT:");
// for(String s: a[i].split(":")){
// System.out.println(s);
// }
// System.out.println("-----");
// }
}
} catch (Exception e) {
System.out.print(e);
}
}
}
Re: Splitting a japanese sentense using colon
Quote:
Originally Posted by
sarathuob
[B]i want to split a japanese sentense using colon.. i can split a sentense which is having english before colon and japanese after that example (hello how are u :芝ダイレクト Yahoo!店") .. i can spliut this but i could not be able to split the below sentense .
|||||||||||[PR]3日前にストアがつぶやきましたレビュー:1件評価:-ストア:東芝ダイレクト Yahoo!店"
can any one help me to do this please .. this is the program i have tried
import java.io.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.regex.Pattern;
public class SplitString {
public static void main(String args[]) {
try {
String str = "|||||||||||[PR]3日前にストアがつぶやきましたレビュー:1件評価:-ストア:東芝ダイレクト Yahoo!店";
String[] a, b;
str = URLEncoder.encode(str, "UTF-8");
a = str.split(":");
//System.out.println(str);
//System.out.println(URLEncoder.encode(":", "UTF-8"));
// System.out.println(a[1]);
for (int i = 0; i < a.length; i++) {
System.out.println(URLDecoder.decode(a[i], "UTF-8"));
// if(a[i].contains("//:")){
// System.out.println("SPLIT:");
// for(String s: a[i].split(":")){
// System.out.println(s);
// }
// System.out.println("-----");
// }
}
} catch (Exception e) {
System.out.print(e);
}
}
}
Hi sarathuob,
[/CODE]
public static void main(String args[]) {
try {
String str = "|||||||||||[PR]3日前にストアがつぶやきましたレビュー:1件評価:-ストア:東芝ダイレクト Yahoo!店";
String[] a, b;
a = str.split(":");
System.out.println( a.length );
for (int i = 0; i < a.length; i++) {
System.out.println(URLDecoder.decode(a[i],"UTF8"));
}
} catch (Exception e) {
System.out.print(e);
}
}
[/CODE]
Just save your .java file in UTF-8 format.
Re: Splitting a japanese sentense using colon
when you save your file in UTF-8 format there is no need for encoding and decoding.
you can save your file in UTF-8 format using Eclispe, Edit Plus and many more editors.
hope it helps you.
Re: Splitting a japanese sentense using colon
Re: Splitting a japanese sentense using colon
thank you very much viren.. it works for me .. :)