Molkrot
Molkrot

Reputation: 55

Jquery 1.9 preg replace text in url

Below is my local url

Example : http://localhost/project/admin/resources/view_category/199

I need delete all text after resources and replace it with jquery

Example : http://localhost/project/admin/resources/please_help).

Syntax of preg_math functions i don't know.

Upvotes: 0

Views: 84

Answers (1)

Anton
Anton

Reputation: 32591

Use .split()

var str = "http://localhost/project/admin/resources/view_category/199"
    str = str.split("resources")[0] + "resources/please_help"
    console.log(str); //"http://localhost/project/admin/resources/please_help"

Upvotes: 1

Related Questions