Hi Friends đź‘‹,

Welcome To Infinitbility! ❤️

To remove double quotes from a string in react native, just use the replaceAll('"', '') method it will replace double quotes with an empty string and return a new string without double quotes.

Like the following example, let’s take the below sample string example here we will remove all double quotes available in the string.

const str = 'Hi" Friend"s, Welcome "to" infinitbility';

// 👇️ 'Hi Friends, Welcome to infinitbility'
str.replaceAll('"', '');

Today, I’m going to show you How do I remove double quotes from strings in react native, as above mentioned here, I’m going to use the replaceAll() method and print output on the app screen.

Let’s start today’s tutorial how do you remove double quotes from a string in react native?

In this example, we will do

  1. Create a sample string state
  2. Remove double quotes using the replaceAll method
  3. Print output on the screen

Let’s write code…

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

const App = () =>  {
    const [str, setStr] = useState('Hi" Friend"s, Welcome "to" infinitbility');

    useEffect(() => {
      let newStr = str.replaceAll('"', '');
      console.log(newStr);
    }, []);

    return (
        <View style={styles.container}>
            <Text>{str.replaceAll('"', '')}</Text>
        </View>
    );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  paragraph: {
    margin: 24,
    fontSize: 18,
    fontWeight: 'bold',
    textAlign: 'center',
  },
});

export default App;

As mentioned above, we are taking the example of a string state, using the replaceAll() to delete double quotes from the string and print output on the app screen.

Let’s check the output.

React Native, remove double quotes from string example
React Native, remove double quotes from string example

Try it yourself

I hope it’s help you, All the best 👍.