How to remove the unwanted characters and special symbols using regular expression?

조회 수: 20 (최근 30일)
How to remove the unwanted string given below using regular expression
Input: 21;#700J Crawler- Pre-Calibration_Template.xlsm;19
Desired output: 700J Crawler- Pre-Calibration_Template
  댓글 수: 2
Guillaume
Guillaume 2018년 11월 29일
You can do almost anything with regular expressions as long as the rules are clearly defined. In your particular case, you need to define what unwanted string actually is before we can answer.
Regular expressions work on patterns, so you need to clearly define either which patterns are not allowed, or which patterns are allowed. It seems that numbers are only acceptable in some cases (which cases?) and some patterns of letters and symbols are not allowed (which patterns?)
raghavendra kandukuri
raghavendra kandukuri 2018년 11월 29일
Hi Guillaume,
everything before '#' and every thing after'.' need to be cleared or truncated

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2018년 11월 29일
편집: Guillaume 2018년 11월 29일
"everything before '#' and every thing after'.' need to be cleared or truncated"
then it's very easy:
regexp(yourinput, '(?<=#)[^.]+', 'match')
which basically keeps everything after the first # until it encounters a .

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by