I have created a singup button as follows:

```
signupButton = [[UIButton alloc] initWithFrame:CGRectMake(10,(facebookLoginButton.bounds.size.height + 40),300,50)];
signupButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
UIImage *signupButtonImage = [[UIImage imageNamed:@"Signup"]
                              resizableImageWithCapInsets:UIEdgeInsetsMake(0, 10, 0, 10)];
[signupButton setBackgroundImage:signupButtonImage forState:UIControlStateNormal];

```

The frame for the button is 300x50 per the above. I have created an image (for Retina devices) as 22(w)x100(h)px.

The image is 22 pixels which includes 10px rounded corners and 2px which are for the repeatable middle section.

I have tried to implement the stretch per the above code with insets as 0,10,0,10 but this does not stretch as expected.

![enter image description here](https://i.stack.imgur.com/5aiBT.png)

![Actual image](https://i.stack.imgur.com/MiNNJ.png)

Can someone explain what the insets should be? Also how to work these out, I cannot find any useful information on how to actually calculate what the insets should be? I have read the Apple documentation on this, but I do not understand how to work these out.
['https://Stackoverflow.com/questions/15722072', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1523603/']
You don't need the starting and trailing `.*`, but you do need to escape the `$` as it has the special meaning of the zero-width end of the string.

```
\\$_POST\\['[a-zA-Z0-9]*'\\]

```
You can use the regex pattern given as a String with the [matches(...) method](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#matches%28java.lang.String%29) of the [String class](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#matches%28java.lang.String%29). It returns a `boolean`.

```
String a = "Hello, world! $_POST['something'] Test!";
String b = "Hello, world! $_POST['special!!!char'] Test!";
String c = "Hey there $_GET['something'] foo bar";

String pattern = ".*\\$_POST\\['[A-Za-z0-9]+'\\].*";

System.out.println ("a matches? " + Boolean.toString(a.matches(pattern)));
System.out.println ("b matches? " + Boolean.toString(b.matches(pattern)));
System.out.println ("c matches? " + Boolean.toString(c.matches(pattern)));

```

You can also use a [Pattern](http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) and a Matcher object to reuse the pattern for multiple uses:

```
String[] array = {
    "Hello, world! $_POST['something'] Test!",
    "Hello, world! $_POST['special!!!char'] Test!",
    "Hey there $_GET['something'] foo bar"
};

String strPattern = ".*\\$_POST\\['[A-Za-z0-9]+'\\].*";
Pattern p = Pattern.compile(strPattern);

for (int i=0; i<array.length; i++) {
    Matcher m = p.matcher(array[i]);
    System.out.println("Expression:  " + array[i]);
    System.out.println("-> Matches?  " + Boolean.toString(m.matches()));
    System.out.println("");
}

```

outputs:

```
Expression:  Hello, world! $_POST['something'] Test!
-> Matches?  true

Expression:  Hello, world! $_POST['special!!!char'] Test!
-> Matches?  false

Expression:  Hey there $_GET['something'] foo bar
-> Matches?  false

```