Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Insert left/right at X position X characters #10

Open
hflatoey opened this issue Nov 23, 2022 · 3 comments
Open

[Request] Insert left/right at X position X characters #10

hflatoey opened this issue Nov 23, 2022 · 3 comments

Comments

@hflatoey
Copy link

hflatoey commented Nov 23, 2022

Hello :)

If it's not to much trouble that is.

Example:

String: 2022.11.23 456 xxxx | 789 xxxx

Insert left "12" "- "

New string: String: 2022.11.23 - 456 xxxx | 789 xxxx

@Steveorevo
Copy link
Owner

You can do this a number of ways; here's one by using a function node:

var data = S("2022.11.23 456 xxxx | 789 xxxx");
data = data.getLeftMost(" ").replaceAll(".", "-") + " - " + data.delLeftMost(" ");
msg.payload = data;

After which, data would be:
2022-11-23 - 456 xxxx | 789 xxxx

@hflatoey
Copy link
Author

Thanks but I thought since the String node could do so much already this would be a nice addition for us that is not good with function code like that.

I also see I made a mistake in my example, new string should have been "2022.11.23 - 456 xxxx | 789 xxxx" and not "2022-11-23 - 456 xxxx | 789 xxxx" as I first typed.

@Steveorevo
Copy link
Owner

You could use controls in the node to perform the methods to getLeftMost and append.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants