0

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 :)

2
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by hiddepolen
0

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.

0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.