I have a few strings that I am trying to match against
- Cafe Team Member: Grovedale (Featured)
- Cafe Team Member: Barwon Heads (Featured)
- Cafe Team Member: Barwon Heads
What I have been able to come up with is /(?<=\:\s)(.+)(?=\s\()/g which will work for options one and two but 3 (because I am looking for an open bracket after the location) it will not work. I am stumped about how else I could go about this.
Edit:
Figured all i needed to add was |$ so it now looks like /(?<=\:\s)(.+)(?=\s\(|$)/g but when testing it in codepen it still isn't capturing the string correctly. Where regexr is saying it should work.
// vue stuff
new Vue({
el: "#app",
data: {
titles: [
"Cafe Team Member: Grovedale (Featured)",
"Cafe Team Member: Barwon Heads (Featured)",
"Cafe Team Member: Barwon Heads",
]
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<template v-for="title in titles">
<p>{{ title.match(/(?<=\:\s)(.+)(?=\s\(|$)/g) }}</p>
</template>
</div>