Hi Friends đź‘‹,

Welcome To Infinitbility! ❤️

To get string after specific character in javascript, use split() method with pop() method it will return those string which after then your specific character 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 character.

string.split("-").pop();

Today, I’m going to show you How do I get string after specific character 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 character in javascript?

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

Javascript get string after specific character example

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

let string = "infinitbility@2022";

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

console.log(afterLifeStr)

// Output
// '2022'

Output

Typescript get string after specific character example

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

let string: string = "infinitbility@2022";

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

console.log(afterLifeStr)

// Output
// '2022'

Output

React js get string after specific character example

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

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

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

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

Output

React native get string after specific character example

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

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

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

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

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

Output

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