Check string to see if it DOES NOT start with "x" Check string to see if it DOES NOT start with "x"

Dear UiPathers

Is it possible to check if something DOES NOT start with something else?
An example could be, I want to test if a string DOES NOT start with the letter “x”?

Is there an efficient way to do that?

HI @nmjvk

Can you share the sample input string and expected output?



Try with this,

Not (yourStringVariable.StartsWith("yourStringToCheck", StringComparison.OrdinalIgnoreCase))

HI @nmjvk

You can try with Regex Expression






Not string_name.startswith("x")


Not YourStringVar.Trim().StartsWith("x")
Or (harmonized)
Not YourStringVar.Trim().ToUpperStartsWith("X")

Here I have an if condition where I am looping through all of my columns. I want to say "if the column DOES NOT START with (“P-enhedens”)

I get this error when trying to do your solution

HI @nmjvk

Try with this expression




You have duplicate variable in the panel delete any one of them and check it @nmjvk

For each Activity: item in dt.Columns.Cast(Of DataColumn).Select(Function (x) x.ColumnName)
TypeArgument: String

If Activity: Not item.Trim().StartsWith(“P-enhedens”) - when it should be negated, otherwise ommit the Not
Then: Remove DataColumn use Colname: item
Else: do other things

Kindly note: we are looping over the names because of would we loop over the columns and delete a column we would get a collection modified exception

As an alternate we can alos loop over dt.Clone.Columns then we can delete columns from original datatable without collection modified exception

I keep getting the same error

I come from a programming background, I know most langauges support negation such as “Not(something)” which works perfect, it’s simple and easy to read. Does UiPath offer the same?

This we can never know when we do read a question.Perfect with all given samples you can finalize and close the topic

Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

Your variable is not initialized properly. Can you check the variable Ft2 and Counter?

That’s it, I did not properly declare my variable. Solutions given by @sarathi125 and @ronconi works the best for me. I will accept @sarathi125 answer since he was the first. Thanks!

1 Like

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