79 0009!017009!0479%0009!0479 0009!0469%0009!0469 0009!0459%0009!0459'009 0009!0459%0009!0449 0009!0449%0009!0449 0009!0439%0009!0439 0009!0429%0009!0429'009 0009!0429%0009!0419 0009!0419%0009!0409 000'009!0399 0009!0389%0009!0389'009 0009!0379%0009!0369 0009!0349%0009!0349 0009!0339%0009!0339 0009!0339%0009!0329'009 0009!0329%0009!0329 0009!032


In this data, I'm supposed to extract the number 47, 46 , 45 , 44 and so on. Im supposed to avoid the rest. The numbers always follow this flow - 9!0 no 9%
for example: 9!0 42 9%
Which language should I go about to solve this and which function might help me?
Thank you :)

Recommended Answers

All 3 Replies

I hope you are familiar to Regex. You can use that to match a set of characters in a string, perfect for you.
The test code below is from http://www.xinotes.org/notes/note/1319/.

import java.util.regex.*;

public class RegExFindAll {
    public static void main(String[] args) {
	String str = "You can use a Matcher to find all matches to a regular repression";

	// find all words starting with m or c, and ends with n or r or s. 
	// RegEx backslash should be escaped with an additional one.
	Pattern p = Pattern.compile("\\b(m|c)\\w*(n|r|s)\\b");
	Matcher m = p.matcher(str);
	while (m.find()) { // find next match
	    String match = m.group();
	    System.out.println(match);
	}

        // false because regex does not match the whole string
        System.out.println("Matches: " + m.matches());
    }
}

What does it do? It makes a Matcher object, that matches al the strings containing the letters specified in the code. You should make your own Regex string, so that your values match.

Is there any function that can position a special character and copy the next two or three elements?
Ex: 9!0 42 9%
look out for ! and then copy 42 from there

Your post did help me but have a special case now. thanks a lot for the help

I hope you are familiar to Regex. You can use that to match a set of characters in a string, perfect for you.
The test code below is from http://www.xinotes.org/notes/note/1319/.

import java.util.regex.*;

public class RegExFindAll {
    public static void main(String[] args) {
	String str = "You can use a Matcher to find all matches to a regular repression";

	// find all words starting with m or c, and ends with n or r or s. 
	// RegEx backslash should be escaped with an additional one.
	Pattern p = Pattern.compile("\\b(m|c)\\w*(n|r|s)\\b");
	Matcher m = p.matcher(str);
	while (m.find()) { // find next match
	    String match = m.group();
	    System.out.println(match);
	}

        // false because regex does not match the whole string
        System.out.println("Matches: " + m.matches());
    }
}

What does it do? It makes a Matcher object, that matches al the strings containing the letters specified in the code. You should make your own Regex string, so that your values match.

Well, you can use the Matcher from above, if you edit the Regex a little.
Let it match 9!0[any two numbers)9%. (You can think yourself how that Regex looks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.