Reputation: 168
Can any one give the regular expression for checking a string prior to .pdf
For example: I want the text angular
from the string angular.pdf#2345
or angular.pdfthis
.
Upvotes: 0
Views: 291
Reputation: 386680
You could use a regular expression with a positive lookahead.
/.*(?=\.pdf)/
console.log('angular.pdf#2345'.match(/.*(?=\.pdf)/));
Upvotes: 2
Reputation: 3994
Seems your example clarifies what you really want.
str.substring(0,str.indexOf(".pdf"))
Upvotes: 1
Reputation: 2644
What about this:
(.*)\.pdf.*
The first matching group will contain the string prior to .pdf
.
See this example.
Upvotes: 1