Julia - Space notch lines and length checks

I'm new to Julia, and I was wondering if there are any built-in functions to trim the string? I also want to check the length of the string, which, as I know, I can do with length(s) == 0, but I wondered if there are other built-in functions there? Thank you

I am basically trying to find the Julia equivalent for the following MATLAB code:

line = strtrim(line);        
if isempty(line), continue; end % Skip empty lines 
+4
source share
2 answers

lstripfor leading spaces, rstripfor trailing spaces, stripfor both.

There is a function for julia isempty:

isempty("")
>> true

, Julia (http://docs.julialang.org/en/release-0.5/stdlib/strings/ http://docs.julialang.org/en/release-0.5/manual/strings/)

+6

/

lstrip(string)
rstrip(string)

, -

a = "a b c d e f"
join(map(x -> isspace(a[x]) ? "" : a[x], 1:length(a)))

, , " " ' '

filter(x -> !isspace(x), a)

Fengyang Wang,

+4

Source: https://habr.com/ru/post/1663541/


All Articles