Лучший отвечающий
Regular expression question

Вопрос
-
Dear experts,
I have a requirement to create regular expression for following string:
"username;;;;pos id;org;user type (mobile)"
After that will need to call any of values in each block like $matches[1],$matches[2]...,$matches[7]. Separator between blocks is ;
Thank you for your help.
- Изменено zotchy 26 октября 2011 г. 11:17
26 октября 2011 г. 11:16
Ответы
-
-match "(.*);(.*);(.*);(.*);(.*);(.*);(.*)"
- Помечено в качестве ответа KazunEditor 31 октября 2011 г. 11:58
27 октября 2011 г. 8:35Отвечающий
Все ответы
-
PS > "username;;;;pos id;org;user type (mobile)" | ConvertFrom-Csv -Delimiter ";" -Header 1,2,3,4,5,6,7,8 1 : username 2 : 3 : 4 : 5 : pos id 6 : org 7 : user type (mobile) 8 : $data = "username;;;;pos id;org;user type (mobile)" | ConvertFrom-Csv -Delimiter ";" -Header 1,2,3,4,5,6,7,8 PS > $data."1" username PS > $data."2" PS > $data."7" user type (mobile) or you may using PS > "username;;;;pos id;org;user type (mobile)" -split ";" username pos id org user type (mobile) PS > $data = "username;;;;pos id;org;user type (mobile)" -split ";" PS > $data[0] username PS > $data[6] user type (mobile)
26 октября 2011 г. 11:34Отвечающий -
Thank you for yor help.But is it possible to make it using -match operator?
I am trying to make a mask using this:
-match "(\S+);(\S+);(\S+);(\S+);(\S+);(\S+);(\S+)"
but is doesn't work. What I am doing wrong? It returns me "False" (like it cannot fit the mask into string)
- Изменено zotchy 27 октября 2011 г. 8:18
27 октября 2011 г. 8:17 -
-match "(.*);(.*);(.*);(.*);(.*);(.*);(.*)"
- Помечено в качестве ответа KazunEditor 31 октября 2011 г. 11:58
27 октября 2011 г. 8:35Отвечающий -
Это русскоязычный форум - используйте русский язык для общения.
Сазонов Илья http://www.itcommunity.ru/blogs/sie-wl/28 октября 2011 г. 2:59Модератор