REGEX - extract some text in a string

Asked

Viewed 1,004 times

0

i have the following string ==> "The guy from Pamonha crashed his car into the guy’s car" I am wanting to extract starting from ("the guy ...") and ending in ("... the car")$ someone could help me with this RE

1 answer

2


If the goal is just to select this piece you could go straight to the point:

/o cara da pamonha bateu com o carro/

Or you can use this pattern:

/o cara(.*)no carro/

See the example.


UPDATE

So if you want to stop at the first word "car" and return everything from the beginning of the sentence use this pattern:

/^(.*?)carro/

Example

  • that question is only an illustration of my real problem and there is a Portuguese import in the string I want my regex end in the first car word and not in the second car word look what happened i.stack.Imgur.com/Qzojs.png

  • I don’t understand what exactly you want to extract? You can give more details?

  • @Magichat in my string has two words car. I want my re to end at the first word car

  • Put the re that has tried and the mistake that is giving...

  • 1

    see the update I made

  • solved your problem?

  • 1

    @zwitterion positive! thanks for the helpfulness :)

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.