Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get text between two characters?

Tags:

|text to get| Other text.... migh have "|"'s ...

How can I get the text to get stuff from the string (and remove it)?

It should be just the first match

like image 512
Ella Avatar asked Sep 09 '11 17:09

Ella


People also ask

How do I extract text between two instances of a character?

Select a cell which you will place the result, type this formula =MID(LEFT(A1,FIND(">",A1)-1),FIND("<",A1)+1,LEN(A1)), and press Enter key. Note: A1 is the text cell, > and < are the two characters you want to extract string between.

How do I get text between two words in Excel?

In the Cell box, select a cell where you want to extract the text (here I select cell B5); In the Start char(s) box, enter the start word of the two words you want to extract all text strings after it; In the End char(s) box, enter the end word of the two words you want to extract all text strings before it.


1 Answers

var test_str = "|text to get| Other text.... migh have \"|\"'s ...";
var start_pos = test_str.indexOf('|') + 1;
var end_pos = test_str.indexOf('|',start_pos);
var text_to_get = test_str.substring(start_pos,end_pos)
alert(text_to_get);
like image 72
reader_1000 Avatar answered Sep 29 '22 01:09

reader_1000