Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

count a string

count a string

count a string

hi all:

I want to count a word in a text file by using as condition the last character and put result into 3 edittext .

if I have for example the word MACNAME(X or Y or Z) which will be parsed from text file .




the last character is X & Y & Z .

put the result in jedittext :

e1.gettext('count of number of MACNAMEX' );// here is 1
e2.gettext('count of number of MACNAMEY' );// here is 1
e3.gettext('count of number of MACNAMEZ' );// here is 1

I 'm doing GUI application which import text file and count a word by using regx.

I have used scanner method to import text

try (Scanner sc = new Scanner(new File("C:\\MAC.txt"))) {

the REGX used is:

private static String REG ="((?<MACNAME>\\w+)";

how to do that ?

RE: count a string

There are a lot of ways for doing that, for example you can take a look at the Matcher class


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close