Navigate back to the homepage

how to remove double quotes from string in react native?

Infinitbility
React Native
July 6th, 2022 · 1 min read
how to remove double quotes from string in react native?

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.

1const str = 'Hi" Friend"s, Welcome "to" infinitbility';
2
3// 👇️ 'Hi Friends, Welcome to infinitbility'
4str.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…

1import React, { useState, useEffect } from 'react';
2import { Text, View, StyleSheet } from 'react-native';
3
4const App = () => {
5 const [str, setStr] = useState('Hi" Friend"s, Welcome "to" infinitbility');
6
7 useEffect(() => {
8 let newStr = str.replaceAll('"', '');
9 console.log(newStr);
10 }, []);
11
12 return (
13 <View style={styles.container}>
14 <Text>{str.replaceAll('"', '')}</Text>
15 </View>
16 );
17}
18
19const styles = StyleSheet.create({
20 container: {
21 flex: 1,
22 justifyContent: 'center',
23 backgroundColor: '#ecf0f1',
24 padding: 8,
25 },
26 paragraph: {
27 margin: 24,
28 fontSize: 18,
29 fontWeight: 'bold',
30 textAlign: 'center',
31 },
32});
33
34export 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 👍.

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 replace string in node js?

how to replace string in node js?

An example of replace string in node js with a step-by-step example.

July 6th, 2022 · 1 min read
how to check if string contains substring in react js?

how to check if string contains substring in react js?

An example of check string contains substring in react js with a step-by-step example.

July 5th, 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]