Navigate back to the homepage

how to get string after specific word in javascript?

Infinitbility
JavaScript
August 24th, 2022 · 1 min read
how to get string after specific word in javascript?

Hi Friends 👋,

Welcome To Infinitbility! ❤️

To get string after specific word in javascript, use split() method with pop() method it will return those string which after then your specific word or which you used to split the string.

Let’s see short example to use split() method with pop() method to get string after specific word.

1string.split("WORD").pop();

Today, I’m going to show you How do I get string after specific word in javascript, as above mentioned, I’m going to use the above-mentioned split() method with pop() method.

Let’s start today’s tutorial how do you get string after specific word in javascript?

Here, I will show get string after specific word examples in javascript, typescript, react js and react native.

Javascript get string after specific word example

Here, we will take string variable with some data and use split() with pop() method to get string after specific word in javascript.

1let string = "infinitbility and aguidehub";
2
3let afterLifeStr = string.split("and").pop();
4
5console.log(afterLifeStr)
6
7// Output
8// ' aguidehub'

Output

Typescript get string after specific word example

Here, we will take string variable with some data and use split() with pop() method to get string after specific word in typescript.

1let string: string = "infinitbility and aguidehub";
2
3let afterLifeStr: string = string.split("and").pop();
4
5console.log(afterLifeStr)
6
7// Output
8// ' aguidehub'

Output

React js get string after specific word example

Here, we will take string state with some data and use split() with pop() method to get string after specific word in react js.

1import React, { useState, useEffect } from "react";
2export default function App() {
3 const [str, setStr] = useState("infinitbility and aguidehub");
4
5 useEffect(() => {
6 let afterLifeStr = str.split("and").pop();
7 console.log(afterLifeStr)
8 }, []);
9
10 return (
11 <div className="App">
12 {str.split("and").pop()}
13 </div>
14 );
15}

Output

React native get string after specific word example

Here, we will take string state with some data and use split() with pop() method to get string after specific word in react native.

1import React, { useState, useEffect } from "react";
2import { Text, View } from 'react-native';
3
4export default function App() {
5 const [str, setStr] = useState("infinitbility and aguidehub");
6
7 useEffect(() => {
8 let afterLifeStr = str.split("and").pop();
9 console.log(afterLifeStr)
10 }, []);
11
12 return (
13 <View>
14 <Text>{str.split("and").pop()}</Text>
15 </View>
16 );
17}

Output

I hope it helps you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

how to get string after specific character in javascript?

how to get string after specific character in javascript?

An example of get string after specific character in javascript with the step-by-step guide.

August 23rd, 2022 · 1 min read
how to get last word of string in react js?

how to get last word of string in react js?

An example of get last word of string in react js with the step-by-step guide.

August 22nd, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]