I have the following string. I want to get everything before the character |
'abc eff 23 aaa|C:\\WINDOWS|\\Device\\Harddisk\\Parti'
My output should be like 'abc eff 23 aaa'
How do i get it.. Please help me with this
I have the following string. I want to get everything before the character |
'abc eff 23 aaa|C:\\WINDOWS|\\Device\\Harddisk\\Parti'
My output should be like 'abc eff 23 aaa'
How do i get it.. Please help me with this
You would use the built-in 'split' function as such:
'abc eff 23 aaa|C:\\WINDOWS|\\Device\\Harddisk\\Parti'.split('|')[0]
Here is the documentation on how it works if you are curious.
There are 2 methods you can use here either use string.split('|')[0]
or string[:string.find('|')]
(as a string is an array you can do this as well)