Display Block RegExp Regular Expressions info

    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    Hello, I would like more information about the expressions that can be used in the display blocks, it is very difficult for those (myself included) who have never touched this programming language.

    Perhaps a special command written in the block display, can display that information.

    Some examples would be much help
     

    jayman38

    Precentor-Primus, pro-tempore
    Joined
    Jul 13, 2014
    Messages
    2,518
    Reaction score
    787
    • Purchased!
    • Thinking Positive
    • Legacy Citizen 4
    I have been learning Regular Expressions for years, mostly within the GVIM program. It has been amazingly useful to learn.
     
    • Like
    Reactions: nightrune

    Ithirahad

    Arana'Aethi
    Joined
    Nov 14, 2013
    Messages
    4,150
    Reaction score
    1,330
    • Purchased!
    • Top Forum Contributor
    • Legacy Citizen 8
    For basic functions, you don't really need to know much regex. For instance, if you want a docking status thing:

    [REPLACEALL]Docking Port 1: Open[WITH]Docking Port 1: Closed

    Second display module:

    [REPLACEALL]Docking Port 1: Closed[WITH]Docking Port 1: Open
     
    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    I know all the new operation of the new display options, I do not understand very well the expressions regexp
     
    Joined
    Jul 30, 2013
    Messages
    398
    Reaction score
    282
    • Wired for Logic Gold
    • Legacy Citizen 8
    • Purchased!
    what happen if i only want match one character in a specific position of one string line? what Regex xpresion could i use?

    for example:

    i want to mach if in the last position (in this case 5) is the letter "E", and replace it with "e"
    HOUSE -- HOUSe

    also.. the [DEL] display command, only "remove" the last character from the first line, so if i have this string "abc", the [DEL] command only do this "abc" - "ab_" - "a_ _" - "_ _ _", what happen if i want do that in reverse? "_ bc" - "_ _ c" - "_ _ _"

    there are any RegEx expresion i can use?
     
    Joined
    Mar 2, 2014
    Messages
    1,293
    Reaction score
    230
    • Thinking Positive
    • Community Content - Bronze 1
    • Legacy Citizen 3
    what happen if i only want match one character in a specific position of one string line? what Regex xpresion could i use?

    for example:

    i want to mach if in the last position (in this case 5) is the letter "E", and replace it with "e"
    HOUSE -- HOUSe

    also.. the [DEL] display command, only "remove" the last character from the first line, so if i have this string "abc", the [DEL] command only do this "abc" - "ab_" - "a_ _" - "_ _ _", what happen if i want do that in reverse? "_ bc" - "_ _ c" - "_ _ _"

    there are any RegEx expresion i can use?
    I don't think that's possible.
    Code:
    [REPLACEFIRST]E$[WITH]e
    This would work in your "HOUSE" example, but not for other positions than the end.
    Code:
    [REPLACEFIRST][^_][WITH]_
    This would replace the first character that isn't an underscore with an underscore, but it seems to be impossible to replace something with nothing. If you replaced both underscores in the above code with a zero width space, you'd get the desired appearance, but you'd end up with an increasing number of invisible characters.

    Check Wikipedia for more info.
     

    jayman38

    Precentor-Primus, pro-tempore
    Joined
    Jul 13, 2014
    Messages
    2,518
    Reaction score
    787
    • Purchased!
    • Thinking Positive
    • Legacy Citizen 4
    what happen if i only want match one character in a specific position of one string line? what Regex xpresion could i use?

    for example:

    i want to mach if in the last position (in this case 5) is the letter "E", and replace it with "e"
    HOUSE -- HOUSe

    also.. the [DEL] display command, only "remove" the last character from the first line, so if i have this string "abc", the [DEL] command only do this "abc" - "ab_" - "a_ _" - "_ _ _", what happen if i want do that in reverse? "_ bc" - "_ _ c" - "_ _ _"

    there are any RegEx expresion i can use?
    I haven't tested yet, but based on the RegEx page that Bench linked above, this might be worth a try:
    Code:
    [REPLACEFIRST]^\S{4}\G\S[WITH]e
    How it is supposed to work:
    The carat refers to the beginning of the line.
    The backslash-S refers to any non-space character (alphanumeric, plus maybe special characters.)
    The 4 sandwiched between curly-braces counts out exactly four of those non-space characters.
    The backslash-G refers to a meta command to go to the end of the current match (the four non-space characters).
    The backslash-S finds the fifth non-space character. This should be the only character selected at this point.
    That fifth character should get replaced with "e".

    Alternatively, if you do want to find an "E" at the end of the line, Malacodor's "E$" should find it.

    For deleting in reverse, it may be worth a try to use the "counting" trick above.

    Example to delete the first character of a line:
    Code:
    [REPLACEFIRST]^\S{1}[WITH][]
    Note that there is nothing between the matching pair of square brackets after the "WITH" keyword. That first non-space character should simply be gone.

    Example to delete the first two characters of a line:
    Code:
    [REPLACEFIRST]^\S{2}[WITH][]
    Note that there is nothing between the matching pair of square brackets after the "WITH" keyword. Those first two non-space characters should simply be gone.

    Try these out and let us know how it goes.