Question: How do I make it so that a desktop UWP app will resize based on resolution? Mainly I need it to work between a surface pro and a Surface Studio. I've researched around google and I haven't seen anything that goes into detail. I know of things like RelativePanel and VisualStateManagers, but I have not clue how to use them. Any guidance would be much appreciated.

Answer: 
There are many alternative ways:

1. Use Java-Stream API on splitted String with `\` delimiter:

```
String str = "/service1/api/v1.0/foo/{fooId}/boo";  
String[] split = str.split("\\/");
String url = Arrays.stream(split).skip(4).collect(Collectors.joining("/"));
System.out.println(url);

```

With the elimination of the parameter, the Stream would be like:

```
String url = Arrays.stream(split)
    .skip(4)
    .map(i -> i.replaceAll("\\?.+", ""))
    .collect(Collectors.joining("/"));

```
2. This is also where [Regex](https://regex101.com/r/yB3Ouo/1) takes its place! Use the classes Pattern and Matcher.

```
String str = "/service1/api/v1.0/foo/{fooId}/boo";

Pattern pattern = Pattern.compile("\\/.*?\\/api\\/v\\d+\\.\\d+\\/(.+)");
Matcher matcher = pattern.matcher(str);
while (matcher.find()) {
    System.out.println(matcher.group(1));
}

```

---

If you rely on the `indexOf(..)` usage, you might want to use the while-loop.

```
String str = "/service1/api/v1.0/foo/{fooId}/boo?parameter=value"; 

String string = str;
while(!string.startsWith("v1.0")) {
    string = string.substring(string.indexOf("/") + 1);
}

System.out.println(string.substring(string.indexOf("/") + 1, string.indexOf("?")));

```

Other answers include a way that if the prefix is not mutable, you might want to use only one call of `idndexOf(..)` method ([@JB Nizet](https://stackoverflow.com/users/571407/jb-nizet)):

```
string.substring("/service1/api/v1.0/".length(), string.indexOf("?"));

```

---

All these solutions are based on your input and fact, the pattern is known, or at least the number of the previous section delimited with `\` or the version `v1.0` as a checkpoint - the best solution might not appear here since there are unlimited combinations of the URL. You have to know all the possible combinations of input URL to find the best way to handle it.
[Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) is quite useful for that : 

```
public static void main(String[] args) {
    Path root = Paths.get("/service1/api/v1.0/foo");
    Path relativize = root.relativize(Paths.get("/service1/api/v1.0/foo/{fooId}/boo"));
    System.out.println(relativize);
}

```

Output :

> 
> {fooId}/boo
> 
> 
>