How do I remove some lines of a text?

0 favourites
  • 8 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hey gus! I have an issue.. Is there any fast solution to remove lines of a text?

    Example:

    Hello there!
    This is a simple test.
    I need to remove this character and
    delete this line,
    and this line..
    Without remove this![/code:2tqvadkc]
    
    What i need, is to find the "character" word, and press delete button. After this to remove the lines above and below.. So to have this result:
    [code:2tqvadkc]This is a simple test.
    Without remove this![/code:2tqvadkc]
    
    Can i? Thank you!!!  ; -)
  • I find this: RegexReplace(Text.Text, ".*character.*\r?\n", "m", "")..

    .. But the result is to remove 1 line (the line with the "character" word) only.

    Can't find any regex to remove 1-2 lines above and 1-2 lines below for example.

  • You can try breaking your text up into individual lines first before working with them using tokenat() and the "newline" expression as your token. Push each line separately into a temporary array and then do whatever you want with them.

  • Thank you for your reply.. but if i need to use a ready text from a file (ajax) for example, and don't want to use array? Can I?

    I think regex is the faster answer (or someone to find better idea of course), but unfortunately can't find the code which can remove above and below lines.

  • Try [\r\n] to match a line break, not sure if it will work though.

  • No working.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The issue here is that you speak of formatting in lines.

    But how does that formatting actually happens ? You speak of a source text coming from AJAX, can you provide an actual example of text ?

    Your example in code in your first post is confusing as it is presented :

    Hello there!
    This is a simple test.
    I need to remove this character and
    delete this line,
    and this line..[/code:54q9qqtl]
    
    [code:54q9qqtl]Hello there!
    Without remove this![/code:54q9qqtl]
    
    Shouldn't actually the result be, in regards to your original text and what you have described (above line and below line):
    [code:54q9qqtl]Hello there!
    and this line..[/code:54q9qqtl]
    
    ?
  • Choice 1: Imagine to write a big text with breaklines in a textbox inside construct 2.

    Choice 2: Now, the same text you can write in a .txt file on windows right? <-- Here is coming ajax plugin in case you want to insert in construct 2.

    Now you have a button.. Click and search for a "character, number whatever" inside your text.

    So this code, a regex code maybe to remove all the line of the "character, number whatever" and 1-2 (maybe 5-10) lines above and 1-2 (maybe 5-10) lines below.

    Hope you understand now! ; -)

    Kyatric

    Sorry, i edit my code example above.. You can see now!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)