Modifying string on java -


I modify the string type xpathes should do the actual exposure by java;

For example;

This type of exemption

_HTML_1__BODY_1__FORM_1__INPUT_3 _

should be turned on

/ html [1] / body [1] / form [1] / INPUT [3]

I do not know, please help me please

As the sides said, the string is irreversible, so you can not change them.

However, after saying this, you can use the Replace to replace the modified version of the string, for example, in this case:

  string Input = "_HTML_1__BODY_1__FORM_1__INPUT_3_"; String output = input.replaceAll ("_ (\\ d +) _", "[$ 1]"). all ("_", "/"); // output = / html [1] / body [1] / form [1] / INPUT [3]   

edit

To explain the rages used in this case:

This method uses two different regular expressions to return a modified string. First, " _ (\\ d +) _ ", appears for numbers encircled by two underscores characters _ , \\ d A regex is short for any number of points to hold the surrounding brackets (...) number so that we can reference it in the replacement string.

When we make the first replacement, we captured the first captured group, i.e. [$ 1] here, at $ 1 And it surrounds it in square brackets [...] . Underscores are also removed, because they were captured in the expression, if not in the group.

The second replaceAll calls will only be used for all remaining underscore characters in a / .

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -