Question: I have the following input text:

```
Teterboro US [TEB] - 20KM

```

I would like to get the following output :

```
Teterboro US

```

I am using the following expression :

```
.*\[

```

But it I am getting the following result

```
Teterboro US [

```

I would like to get rid of the last space and bracket " ["

I am using JavaScript.

Answer: 
You can use `/.*?(?=\s*\[)/` with `match`; i.e. change `\[` to look ahead `(?=\s*\[)` which asserts the following pattern but won't consume it:

```js
var s = "Teterboro US [TEB] - 20KM";

console.log(
  s.match(/.*?(?=\s*\[)/)
)
```
You can try this pattern:

```
.*(?= \[)

```

It is `positive lookahead assertion` and it works just like you expect.