Friday, July 8, 2016

[TIPS] Extract digit or non-digit from String using JAVA

Single line command to extract digit from a String
Eg. text = All (68)

text = text.replaceAll("\\D+", "");

Output - text = 68

Now \D represent the digit character i.e. 68
Also \d represent the non-digit character i.e. All ()
+ represent one or more time

No comments:

Post a Comment

Read CSV from S3

 import csv def count_records(csv_file):     record_count = 0     first_line = None     last_line = None     # Open the CSV file and read it...