How to add space after every 4th character



  • Please Help me how to add split(exp: space etc...) after every 4th character 😘


  • Admin

    Can you write an example of input and output you want



  • This post is deleted!


  • @Ruri
    input : 964273615243

    output for example space every 3 letters
    split : space
    output : 964 273 615 243


  • Admin

    I'm not sure if you can do this tbh



  • Supposing that every input number that you will get is 12 character length, you can do this like that

    FUNCTION Constant "964273615243" -> VAR "num" 
    
    FUNCTION Substring "0" "3" "<num>" -> VAR "p1" 
    
    FUNCTION Substring "3" "3" "<num>" -> VAR "p2" 
    
    FUNCTION Substring "6" "3" "<num>" -> VAR "p3" 
    
    FUNCTION Substring "9" "3" "<num>" -> VAR "p4" 
    
    FUNCTION Constant "<p1> <p2> <p3> <p4>" -> VAR "Out" 
    
    

    It isn't pretty complex solution, but thats the only way I could make out here


  • Admin

    That's supposing he only has 12 characters though, I was saying that you probably can't make a generalized version without using js or py interpreters.



  • Picture :

    alt text

    Maybe there is a better code for javascript but this works you just need to set the variable value to your number

    BEGIN SCRIPT JAVASCRIPT
    
    var value = '964273615243';
    
    function chunk(str, n) {
        var ret = [];
        var i;
        var len;
    
        for(i = 0, len = str.length; i < len; i += n) {
           ret.push(str.substr(i, n))
        }
    
        return ret
    };
    
    var string = chunk(value, 3).join(' ');
    
    END SCRIPT -> VARS "string"
    


  • @Itamai
    nice method but how can i get auto the value 964273615243 from wordlist
    INPUT : 964273615243:0062309520
    OUTPUT : 964 273 615 243



  • @lamjed001 you can use the numeric wordlist. the slice name is <CODE> then you can add a wordlist with only numbers(every line one number). and change the value of the variable value to CODE. It will get the current line from the Wordlist and assign it to the variable value.

    BEGIN SCRIPT JAVASCRIPT
    
    var value = CODE;
    
    function chunk(str, n) {
        var ret = [];
        var i;
        var len;
    
        for(i = 0, len = str.length; i < len; i += n) {
           ret.push(str.substr(i, n))
        }
    
        return ret
    };
    
    var string = chunk(value, 3).join(' ');
    
    END SCRIPT -> VARS "string"
    

    and your output variable is called string but you can change it how you like i just used something random so that you can see how to do it in javascript.


Log in to reply