Extracting the numeric part from a cell

1 次查看(过去 30 天)
Hi everyone,
I have a column string in this format
"injection-0:94577)"
"injection-0:94578)"
"injection-0:94579)"
"injection-0:94580)"
"injection-0:94581)"
"injection-0:94582)"
"injection-0:94583)"
I want to extract the numeric part that starts with 9 like 94577 from roow one for instance. Can anyone help please? Thank you.

采纳的回答

Paul
Paul 2021-11-17
str = ["injection-0:94577)"
"injection-0:94578)"
"injection-0:94579)"
"injection-0:94580)"
"injection-0:94581)"
"injection-0:94582)"
"injection-0:94583)"]
str = 7×1 string array
"injection-0:94577)" "injection-0:94578)" "injection-0:94579)" "injection-0:94580)" "injection-0:94581)" "injection-0:94582)" "injection-0:94583)"
newstr = extractBefore(extractAfter(str,":"),")")
newstr = 7×1 string array
"94577" "94578" "94579" "94580" "94581" "94582" "94583"
  3 个评论
Paul
Paul 2021-11-17
I would just use double()
str = ["injection-0:94577)"
"injection-0:94578)"
"injection-0:94579)"
"injection-0:94580)"
"injection-0:94581)"
"injection-0:94582)"
"injection-0:94583)"];
newstr = extractBefore(extractAfter(str,":"),")");
d = double(newstr)
d = 7×1
94577 94578 94579 94580 94581 94582 94583

请先登录,再进行评论。

更多回答(1 个)

per isakson
per isakson 2021-11-17
Try
>> extractBetween( "injection-0:94582)", ":", ")" )
ans =
"94582"

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by