Python Regular Expression: Search vs Match

SaiKrishna Tavva
Updated on 17-Apr-2025 18:50:53

381 Views

The built-in Python module re provides re.search() and re.match(), which are powerful regular expression functions. They are commonly used functions for finding patterns in strings, but they behave differently. The re.search() Function The re.search() function checks the entire string for a match. It will return the first match it finds in the string, not just at the beginning. This is helpful when the pattern might appear in the middle or end of the string. If it finds a match, it returns a Match object; if not, it returns None. Example In the following example re.search() function looks through the whole ... Read More

What is the const Keyword in C++

Akansha Kumari
Updated on 17-Apr-2025 18:50:20

744 Views

The const keyword in C++ is a keyword that is used to declare variables and objects as constant, which means the value declared using const cannot be changed or modified later, once they are initialized. This helps them prevent accidental modifications. For example, in a code, if we are using the value of PI, which has a fixed universal value and doesn't need any change, then we can declare it as a constant. When you declare the object with the const keyword, then the compiler places that value in ROM (Read-Only Memory), which protects it from being changed ... Read More

Typedef Declarations in C++

Akansha Kumari
Updated on 17-Apr-2025 18:49:33

583 Views

In C++, typedef is a keyword that is used to create a new name for an existing data type. This helps the users to modify the code according to their preference, making it more readable, friendly, and manageable. Syntax Here is the following basic syntax of typedef in C++; typedef existing_type new_name; Here, existing_type is the original data type given in the C++ standard (e.g., int, float, double, etc.)new_name is the new name assigned to that type. Example Here is the following simple example showcasing the use of typedef in C++: #include using namespace std; // Defining ... Read More

What are Shift Operators in C++

Akansha Kumari
Updated on 17-Apr-2025 18:47:39

7K+ Views

In C++, bitwise operators are used to perform operations on binary numbers. Since computers store all data in the form of binary (0s and 1s), therefore, every value, like decimal numbers, characters, and booleans, is internally represented in binary. for example: 5 = 00000101 and 3 = 00000011 To learn more about how to convert these decimal values to binary, you can visit this page: Decimal to Binary Conversion. Shift Operators in C++ The shift operator is one of the types of bitwise operators, which are used to move bits of a number left or right. There are two types of ... Read More

Match Spaces and Newlines with Python Regex

SaiKrishna Tavva
Updated on 17-Apr-2025 18:46:17

937 Views

Python's built-in module re (regular expression) provides special characters to match spaces, newlines, tabs etc. spaces can be extracted using the pattern " " and newlines can be extracted using the pattern "" The following is a simple overview of these special characters- Whitespace Character \s : Matches any whitespace character. Tab \t : Matches a tab character. Newline : Matches a newline character. Vertical Tab \v : Matches a vertical tab character. Form Feed \f : Matches ... Read More

What is Bitwise OR in C++

Akansha Kumari
Updated on 17-Apr-2025 18:46:04

859 Views

Bitwise operators are the operators that are used to perform operations on bits of a binary representation of a number.Bitwise OR (|) Operator OR Operator (|) is one of the types of bitwise operators, which compares each bit of the first operand to the corresponding bit of the second operand and returns 1 if at least one of the bits is 1; else 0 if both bits are 0. You can think of it as similar to addition in decimal, like 0 + 0 = 0, and all other combinations result in 1. But this ... Read More

Install libxml2 with Python Modules on Mac

Sumana Challa
Updated on 17-Apr-2025 18:44:09

1K+ Views

libxml2 is an open-source XML parsing library which is written in C language and provides all the tools needed to read, parse, modify, validate, and write XML and HTML documents. Installing libxml2 Working with XML data in Python requires parsing libraries. One of the most widely used library for this purpose is libxml2. It is an XML toolkit implemented in C, originally developed for the GNOME project. Python doesn't include libxml2 bindings by default, the most common way to work with libxml2 is through the lxml package. Installing it on macOS is quite challenging. This article tells you about to ... Read More

Passing by Pointer vs Passing by Reference in C++

Revathi Satya Kondra
Updated on 17-Apr-2025 18:40:27

3K+ Views

In C++, If we want to pass arguments to functions we can either pass the actual value, a pointer to the value, or a reference to the value. This concept becomes crucial when we want a function to modify the original variable. So, if we pass parameter to a function either by pass by pointer or pass by reference it will produce the same result. Only difference is that References are used to refer an existing variable in another name whereas pointers are used to store address of variable. It is safe to use reference because it cannot be NULL. ... Read More

Where are the Python Modules Stored

Sumana Challa
Updated on 17-Apr-2025 18:40:22

4K+ Views

What are Python Modules? Python module is a file containing Python functions, variables, constants, and objects with a ".py" extension. This file can be imported inside another program to reuse its functionality. It is quite helpful to understand where the module is stored, some of the reasons include - Troubleshooting errors To install third-party packages correctly To create your known modules To manage multiple Python environments To understand Python's import system Python's Module Search Path When you import ... Read More

Execute Both If and Else Statements in C/C++ Simultaneously

Revathi Satya Kondra
Updated on 17-Apr-2025 18:39:52

453 Views

In this article, we will see how to execute the if and else section simultaneously in a C or C++, code. This solution is a little bit tricky. When the if and else are executed one after another then it is like executing statements where if-else are not present. But here we will see if they are present how to execute them one after another. Let's go through the different ways to simulate execution of both if and else blocks. This may include using functions, macros, or separating logic completely. Using Separate Functions ... Read More

Advertisements