Special characters delete

hi how are things

I have the following case

I need to extract data from names in a database, but this data may or may not contain special characters.

I have a variable called “CostumerClient” and every time a name is assigned to this variable it should remove any special characters if it has any.

How can I solve this in a simple way?

@alexis.mendoza
System.Text.Regularexpression.Regex.Replace(variable,“[^\w\d]+”,“”)

Hi,

If the above special characters doesn’t contains white space, the following helps you.

image

System.Text.RegularExpressions.Regex.Replace(CostumerClient,"[^\w\s]|_","")

If it’s good to remove white spaces, too, the following will work.

System.Text.RegularExpressions.Regex.Replace(CostumerClient,"[\W_]","")

Regards,

1 Like

To extract data from names in a database and remove any special characters, you can use the following steps:

  1. Retrieve the names from the database using a database connection and a SQL query.
  2. Iterate through the names using a loop, such as a For Each loop in UiPath.
  3. For each name, use a regular expression (regex) to remove any special characters.

Here is an example of how this could be implemented in UiPath:
// Connect to the database and retrieve the names.
DataTable namesTable = dbConnection.ExecuteQuery(“SELECT name FROM customers”);

// Iterate through the names.
foreach (DataRow row in namesTable.Rows)
{
// Get the name.
string name = row[“name”].ToString();

// Remove any special characters using a regex.
string cleanedName = Regex.Replace(name, @"[^\w\s]", "");

// Do something with the cleaned name.
Console.WriteLine(cleanedName);

}
This code connects to the database, retrieves the names from the customers table, and iterates through the names. For each name, it removes any special characters using a regex pattern that matches any character that is not a word character or a white space character. The cleaned name is then displayed on the console.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.