Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i need to check if two string are equal with , seperated string using regex. ex a,b is equal to a,b or b,a


What I have tried:

i need to check if two string are equal with , seperated using regex. ex a,b is equal to a,b or b,a
Posted
Updated 15-Dec-20 4:41am
Comments
Richard Deeming 15-Dec-20 10:19am    
Well, go ahead. You have our permission to do that.

Or, in other words: you seem to have forgotten to ask a question.
BillWoodruff 15-Dec-20 11:34am    
if we do your homework, you will learn nothing !

1 solution

Try this to separate them:
^(?<LHS>.+?),(?<RHS>.+?)$

You can them compare the groups.
Me? I'd use string.Split on both strings, then just write a if...else - regex is a good tool, but there is no good reason to use one for this task.
 
Share this answer
 
Comments
[no name] 15-Dec-20 10:48am    
Can you please share with example. i am poor in regex
OriginalGriff 15-Dec-20 11:06am    
Don't use a regex! They are very good at text analysis, but they aren't a processing mechanism: yothe code is much, much simpler and more maintainable with just a split and a tiny bit of code!
[no name] 17-Dec-20 1:48am    
i used
HashSet<string>(inputList).SetEquals(patternList)
[no name] 17-Dec-20 7:09am    
how i need to do the same job in SQL
i.e., i have two column in two diff tables one column has the string a,b and other has b,a i need to treat these as same string to get the id from other table. Please help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900