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.

string.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.

let string = "infinitbility and aguidehub";

let afterLifeStr = string.split("and").pop();

console.log(afterLifeStr)

// Output
// ' 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.

let string: string = "infinitbility and aguidehub";

let afterLifeStr: string = string.split("and").pop();

console.log(afterLifeStr)

// Output
// ' 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.

import React, { useState, useEffect } from "react";
export default function App() {
  const [str, setStr] = useState("infinitbility and aguidehub");

  useEffect(() => {
    let afterLifeStr = str.split("and").pop();
    console.log(afterLifeStr)
  }, []);

  return (
    <div className="App">
      {str.split("and").pop()}
    </div>
  );
}

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.

import React, { useState, useEffect } from "react";
import { Text, View } from 'react-native';

export default function App() {
  const [str, setStr] = useState("infinitbility and aguidehub");

  useEffect(() => {
    let afterLifeStr = str.split("and").pop();
    console.log(afterLifeStr)
  }, []);

  return (
    <View>
      <Text>{str.split("and").pop()}</Text>
    </View>
  );
}

Output

I hope it helps you, All the best đź‘Ť.