Regex solution to extract data from multiple brackets inside a cell
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
I have a situation where in the data have to be extracted from inside a square bracket []. The column doesn't have any pattern. These are some of the values in the column :
abc [xyz-123] nsk
[ahd-246]
uteh[iwyt-798]
[kudgb-3645] jvsux [oikjh-35945] ahfvd [kdytd-2384]
As from the examples above, it doesn't follow any pattern. I just need to extract all the data inside the bracket.
I tried using the expression ".*\[(.*)\].*" (excluding ")
It works for most cases but if the cell contains more than 1 bracket pair, it only picks up one data.
Looking for a solution where in i can extract every data inside any number of square bracket.
Thanks in advance
Solved! Go to Solution.
- Labels:
- Regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
try the regex tool in tokenize mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
@Shahas as @apathetichell mentions, Tokenize can be great here! I've added a couple of extra steps in so you don't have to manually click on how many columns to split by.
RegEx: \[.*?\]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi, @Shahas
Maybe this way as you want:
1- Formula: Copy the field [Text] to [Parse].
2- RegEx: Remove all characters not in [ ] by regular expression.
(?<=\[)([\w-]+?)\]
3- Text To Columns: Split [Parse] to Columns by "]" .
4- Data Cleansing: Remove all null columns.
******
If it can help you , please mark it as a solution and give a like for more share.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
heyy @flying008
The regex which u used provided me with the solution that i was looking for. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Heyy @BS_THE_ANALYST
This also works. Thanks for your time
