Question: I have this code:

```
{% set foto = 'photo_gallery/' ~ {{ image.id }} ~ '/' %}
{% set thumbs = 'photo_gallery/thumbs/' ~ {{ image.id }} ~ '/' %}

<img src="{{ pageTemplate.pageHeader.mainUrl }}{{ image.image |replace({foto: thumbs}) }}">

```

This is give me error:

```
Fatal error: Uncaught Twig_Error_Syntax: A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "punctuation" of value "{". in ......

```

How repair it?

Answer: 
A simple approach (without any dependencies) would look something like this,

```
class Test {

    public static void main (String[] args) throws java.lang.Exception
    {
        String a = "123testes1233iambeginnerplshelp123";
        StringBuffer sb = new StringBuffer();
        for (int i=0; i<a.length()-1; i++) {
            while (i<a.length()-1 && !(!isNumber(a.charAt(i)) && isNumber(a.charAt(i+1)))) {
                sb.append(a.substring(i,i+1));
                i++;
            }
            sb.append(a.substring(i,i+1));
            System.out.println(sb.toString());
            sb.setLength(0);
        }

    }

    private static boolean isNumber (char c) {
        return ((int)c >=48) && ((int)c <= 57);
    }

}

```
my solution

```
public StringSplitNum(){ 
    String someString = "123testes1233iambeginnerplshelp123abc";
    String regex = "((?<=[a-zA-Z])(?=[0-9]))|((?<=[0-9])(?=[a-zA-Z]))";
    List arr = Arrays.asList(someString.split(regex));
    for(int i=0; i< arr.size();i+=2){
    System.out.println(arr.get(i)+ " " + arr.get(i+1));
}

```