Tag: Replace
Find & Replace using Regular Expressions in Eclipse & Visual Studio
Find & Replace is a life saver feature for any programmer. In this article we will discuss how to use Find and Replace in complex situations with Regular Expressions. Find using Regular expressions Many times we need to find some text in source code using Regular Expression and that’s not much difficult i.e. Advertisements Suppose …
Find & Replace using Regular Expressions in Eclipse & Visual StudioRead More
Find and Replace all occurrences of a sub string in C++
In this article we will discuss how to replace all occurrences of a sub string with new string in C++. For example, we have a string i.e. Advertisements “Boost Library is simple C++ Library” And we want replace all occurrences of ‘Lib’ with XXX. Let’s see the different methods to do it, Frequently Asked: Implementing …
Find and Replace all occurrences of a sub string in C++Read More
Java : How to update the value of an existing key in HashMap | put() vs replace()
In this article we will discuss different ways to update the value of an existing key in HashMap in Java. Suppose we have a HashMap of words and their frequency count i.e. Advertisements // Create a Map of words and their frequency count HashMap<String, Integer> mapOfWords = new HashMap<String, Integer>() { { put(“John”, 25); put(“at”, …
Java : How to update the value of an existing key in HashMap | put() vs replace()Read More
Python : How to replace single or multiple characters in a string ?
In this article we will discuss how to replace single or multiple characters in a string in Python. Python provides a str.replace() function i.e. Advertisements str.replace(old, new , count) It returns a new string object that is a copy of existing string with replaced content. Also, If count is not provides then it will return …
Python : How to replace single or multiple characters in a string ?Read More
Python Pandas : Replace or change Column & Row index names in DataFrame
In this article we will discuss how to change column names or Row Index names in DataFrame object. First of all, create a dataframe object of students records i.e. Advertisements students = [ (‘jack’, 34, ‘Sydeny’) , (‘Riti’, 30, ‘Delhi’ ) , (‘Aadi’, 16, ‘New York’) ] # Create a DataFrame object dfObj = pd.DataFrame(students, …
Python Pandas : Replace or change Column & Row index names in DataFrameRead More
Pandas: Replace NaN with mean or average in Dataframe using fillna()
In this article we will discuss how to replace the NaN values with mean of values in columns or rows using fillna() and mean() methods. In data analytics we sometimes must fill the missing values using the column mean or row mean to conduct our analysis. Python provides users with built-in methods to rectify the …
Pandas: Replace NaN with mean or average in Dataframe using fillna()Read More
Python: Replace a character in a string
In this article, we will discuss different ways to replace a character in string in python. Overview: Replace all occurrences of a character in string using replace() Replace the first two occurrences of a character in string Replace a character in a string using regex Replace a character in a string using for loop Replace …
Python String – replace() method
In this article, we will learn to use string class’s replace() function to replace sub-strings in a string in Python. In Python, the String class (Str) provides a method replace() to substitute the sub-strings in a string. But as strings are immutable in Python, this function returns a copy of the calling string object with …
Python: Replace multiple characters in a string
In this article, we will discuss different ways to replace multiple characters in a string in Python. Table of Contents: Replace multiple characters in a string using the replace() Replace multiple characters in a string using the translate () Replace multiple characters in a string using regex Replace multiple characters in a string using for …
Python: Replace character in string by index position
In this article, we will discuss how to replace a character in a string at a specific position. Then we will also see how to replace multiple characters in a string by index positions. Table of Contents Use Python string slicing to replace nth character in a string Python function to replace a character in …
Python: Replace character in string by index positionRead More