Delete the 4 last digits of a message

what I am tryng to do is to delete the las 4 digits of a message and I do not how to do it for a big amount of messages. the type of messages that I have have number comas and leters but the last are numbers and always diferent. I am thinking of using this functions:
fname
Please help.

Answers (1)

KSSV
KSSV on 14 Jul 2021
Edited: KSSV on 14 Jul 2021
str = 'Hello World'
str = 'Hello World'
str(end-3:end) = []
str = 'Hello W'

3 Comments

instead of hello word could you do it for a AIS1 that is a string of 20000x1 where every message is the following way !AIVDM,1,1,,A,13ErMfPP00P9rFpGasc>4?wn2802,0*070000
output = regexprep(AIS1, '\d\d\d\d$', '')
This will delete the last 4 characters provided they are digits. It does not "delete the last four digits", so it would leave "ABC12345D" unchanged, and likewise it would leave "AB123D45" unchanged where "last four digits" would require "AB1D" as output
really useful thank youuu

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Tags

Asked:

on 14 Jul 2021

Commented:

on 14 Jul 2021

Community Treasure Hunt

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

Start Hunting!