split

How to split string that delimiters remain in the end of result?

混江龙づ霸主 提交于 2021-01-04 06:41:06
问题 I have several delimiters. For example {del1, del2, del3 }. Suppose I have text : Text1 del1 text2 del2 text3 del3 I want to split string in such way: Text1 del1 text2 del2 text3 del3 I need to get array of strings, when every element of array is texti deli. How can I do this in C# ? 回答1: String.Split allows multiple split-delimeters. I don't know if that fits your question though. Example : String text = "Test;Test1:Test2#Test3"; var split = text.Split(';', ':', '#'); //split contains an

Split text into sentence even Mr. Mrs. exists in a text

感情迁移 提交于 2021-01-03 07:24:26
问题 I have a problem, I want split a text into sentence using fullstop (.) For instance: Mr. Bean is a British comedy television series of 14 half-hour episodes starring Rowan Atkinson as the title character. Different episodes were written by Atkinson, Robin Driscoll, Richard Curtis and one by Ben Elton. If I split the above text, I got 3 sentences like, 1. Mr. 2. Bean is a British comedy television series of 14 half-hour episodes starring Rowan Atkinson as the title character. Different

Split list into two parts based on some delimiter in each list element in python

柔情痞子 提交于 2021-01-01 09:15:03
问题 I have a python list my_list = ['owner/NN', 'is/VBZ', 'pleasant/JJ', 'and/CC', 'entertaining/JJ', './.'] I want to split it into two parts (based on delimeter '/' presented in each list element), so that I can get two seperate list my_list_1 = ['owner', 'is', 'pleasant', 'and', 'entertaining', '.'] my_list_2 = ['NN', 'VBZ', 'JJ', 'CC', 'JJ', '.'] 回答1: split_items = (i.split('/') for i in my_list) my_list1, my_list2 = zip(*split_items) This creates 2 tuples. If you really need lists, you can

Split list into two parts based on some delimiter in each list element in python

与世无争的帅哥 提交于 2021-01-01 09:11:21
问题 I have a python list my_list = ['owner/NN', 'is/VBZ', 'pleasant/JJ', 'and/CC', 'entertaining/JJ', './.'] I want to split it into two parts (based on delimeter '/' presented in each list element), so that I can get two seperate list my_list_1 = ['owner', 'is', 'pleasant', 'and', 'entertaining', '.'] my_list_2 = ['NN', 'VBZ', 'JJ', 'CC', 'JJ', '.'] 回答1: split_items = (i.split('/') for i in my_list) my_list1, my_list2 = zip(*split_items) This creates 2 tuples. If you really need lists, you can

Split list into two parts based on some delimiter in each list element in python

*爱你&永不变心* 提交于 2021-01-01 09:11:05
问题 I have a python list my_list = ['owner/NN', 'is/VBZ', 'pleasant/JJ', 'and/CC', 'entertaining/JJ', './.'] I want to split it into two parts (based on delimeter '/' presented in each list element), so that I can get two seperate list my_list_1 = ['owner', 'is', 'pleasant', 'and', 'entertaining', '.'] my_list_2 = ['NN', 'VBZ', 'JJ', 'CC', 'JJ', '.'] 回答1: split_items = (i.split('/') for i in my_list) my_list1, my_list2 = zip(*split_items) This creates 2 tuples. If you really need lists, you can

Split a number from a string in JavaScript [duplicate]

余生长醉 提交于 2020-12-30 02:36:03
问题 This question already has answers here : Splitting a string into chunks by numeric or alpha character with JavaScript (3 answers) Closed 3 years ago . I'd like to split strings like 'foofo21' 'bar432' 'foobar12345' into ['foofo', '21'] ['bar', '432'] ['foobar', '12345'] Is there an easy and simple way to do this in JavaScript? Note that the string part (for example, foofo can be in Korean instead of English). 回答1: Check this sample code var inputText = "'foofo21' 'bar432' 'foobar12345'";

Split a number from a string in JavaScript [duplicate]

ぐ巨炮叔叔 提交于 2020-12-30 02:35:41
问题 This question already has answers here : Splitting a string into chunks by numeric or alpha character with JavaScript (3 answers) Closed 3 years ago . I'd like to split strings like 'foofo21' 'bar432' 'foobar12345' into ['foofo', '21'] ['bar', '432'] ['foobar', '12345'] Is there an easy and simple way to do this in JavaScript? Note that the string part (for example, foofo can be in Korean instead of English). 回答1: Check this sample code var inputText = "'foofo21' 'bar432' 'foobar12345'";

Join the string with same separator used to split

一笑奈何 提交于 2020-12-26 07:16:22
问题 I have a string that need to be split with a regular expression for applying some modifications. eg: const str = "Hello+Beautiful#World"; const splited = str.split(/[\+#]/) // ["Hello", "Beautiful", "World"] Now the string has been split with + or # . Now say after applying some modification to the items in the array, I have to join the array using the same separator that used to split, so the character + and # has to be in the same position as before. eg: if i applied some modification

Join the string with same separator used to split

十年热恋 提交于 2020-12-26 07:13:04
问题 I have a string that need to be split with a regular expression for applying some modifications. eg: const str = "Hello+Beautiful#World"; const splited = str.split(/[\+#]/) // ["Hello", "Beautiful", "World"] Now the string has been split with + or # . Now say after applying some modification to the items in the array, I have to join the array using the same separator that used to split, so the character + and # has to be in the same position as before. eg: if i applied some modification

How to split() a string to an array of integers

怎甘沉沦 提交于 2020-12-25 00:33:46
问题 I have a string that should be executed as an array: var q = "The, 1, 2, Fox, Jumped, 3, Over, 4"; var z = q.split(','); If I use split() , it will create an array of strings: [‘The’, '1', '2', ‘Fox’, ‘Jumped’, '3', ‘Over’, '4'] and I don’t need that. I need an array like: [‘The’, 1, 2, ‘Fox’, ‘Jumped’, 3, ‘Over’, 4] indicating which is a string and which is a number. 回答1: One option is using the Number constructor which returns a number or NaN : var res = q.split(',').map(el => { let n =