Is it possible to substring the whole word instead of characters in InfoPath - InfoPath Dev Sign in | Join | Help in Newbie Questions InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Newbie Questions » Is it possible to substring the whole word instead of characters in InfoPath Is it possible to substring the whole word instead of characters in InfoPath Last post 01-26-2012 05:17 PM by yyc2001. 10 replies. Page 1 of 1 (11 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 01-19-2012 03:15 PM yyc2001 Joined on 11-29-2011 Posts 13 Is it possible to substring the whole word instead of characters in InfoPath Reply Contact I know that I can set substring in the rule and apply the rule in the InfoPath. But substring can only get the character out and not the whole word. Is it possible to substring the whole word instead of getting characters. For example, I have this string name input: "Represents text that should be kept confidential." If I use the substring(input, 0, 6) it will give me "Repres". But I'm not too sure if I can get the first 6 word using the rule in InfoPath. Thank you very much. Filed under: infopath 2007, rules, form 01-20-2012 04:34 AM In reply to ErnestoM Joined on 08-27-2007 Posts 3,320 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact Sorry, I guess I'm not understanding. If your input phrase is "Represents text that should be kept confidential", what should be the end result? Ernesto MachadoQdabra® Software/ InfoPathDev.comThe InfoPath Experts – Streamline data gathering to turn process into knowledge.™ 01-20-2012 05:49 AM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact No, I don't think there's anything as simple as what you're asking about, but this should work for getting the first 6 words of a string: substring(field, 1, string-length(field) - string-length(substring-after(substring-after(substring-after(substring-after(substring-after(substring-after(field, " "), " "), " "), " "), " "), " "))) Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 01-20-2012 08:53 AM In reply to yyc2001 Joined on 11-29-2011 Posts 13 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact The end result should be "Represents text that should be kept". So it should print 6 words instead of 6 characters. 01-20-2012 10:19 AM In reply to yyc2001 Joined on 11-29-2011 Posts 13 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact Jimmy:No, I don't think there's anything as simple as what you're asking about, but this should work for getting the first 6 words of a string: substring(field, 1, string-length(field) - string-length(substring-after(substring-after(substring-after(substring-after(substring-after(substring-after(field, " "), " "), " "), " "), " "), " "))) Will this code work if I have for example more than 300 words and I just want to get the first 200?? I tried it but it only give me the first 6 words only. How do I code it so that it will be dynamic. What I mean is that if the length of the field is less than 200 I will get all the string in this field If the length of the field is greater than 200 then I will just get the first 200. 01-21-2012 11:45 AM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact I don't think there is a simple way to make it dynamic. You could modify it to nest more substring-after(..., " ")s in there until you have 200. Why do you want to to get the first 200 words of a string anyway? Wouldn't the number of characters be a more valid measurement in most cases? Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 01-21-2012 11:56 AM In reply to yyc2001 Joined on 11-29-2011 Posts 13 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact Jimmy:I don't think there is a simple way to make it dynamic. You could modify it to nest more substring-after(..., " ")s in there until you have 200. Why do you want to to get the first 200 words of a string anyway? Wouldn't the number of characters be a more valid measurement in most cases? Yes I agree with you. I still need to double check it whether I need to get the first 200 words or just first 200 characters. 01-24-2012 05:08 AM In reply to Skarn Joined on 04-20-2008 Australia Posts 198 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact I can do this, using rules and no code. Can you please confirm for me if the following is correct."User types in words, when they move to next field, any words past the #th word are deleted." where # is a number decided by you.Then, if you cross my palm with gol...hehe kidding. Then I'll post an example template.Part of the solution involves reversing the characters in a field, which I've done, but never had a use for until now. :-P 01-24-2012 09:30 AM In reply to yyc2001 Joined on 11-29-2011 Posts 13 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact Skarn:I can do this, using rules and no code. Can you please confirm for me if the following is correct."User types in words, when they move to next field, any words past the #th word are deleted." where # is a number decided by you.Then, if you cross my palm with gol...hehe kidding. Then I'll post an example template.Part of the solution involves reversing the characters in a field, which I've done, but never had a use for until now. :-P Skarn, Yes it is correct. But I do not delete those words I just read it. What I'm trying to do is to read from one of the field say "Description" that contains any # of words. The rule should take the first 200 words from "Description" and put it into another field "summary". I would appreciate it very much if you could post an example on how you approach this problem. Thank you again for your help!!! 01-26-2012 04:59 PM In reply to Skarn Joined on 04-20-2008 Australia Posts 198 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact hi yyc, my reverse text doesn't work as well as I thought - it suffers from an issue (which isn't really a bad thing) where Infopath won't let rules change a field continuously in case it gets stuck in a loop. I hadn't tested my reverse method with enough characters *blush*. So at this stage I suggest you decide on a number of characters instead and use substring. I could adjust it to do a split based on 'sentences' (ie. look for fullstops, but even that may not be sufficient. Sorry for getting your hopes up, I'm disappointed too, thought I was on to a good solution. 01-26-2012 05:17 PM In reply to yyc2001 Joined on 11-29-2011 Posts 13 Re: Is it possible to substring the whole word instead of characters in InfoPath Mark as Not AnswerMark as Answer... Reply Contact Skarn: hi yyc, my reverse text doesn't work as well as I thought - it suffers from an issue (which isn't really a bad thing) where Infopath won't let rules change a field continuously in case it gets stuck in a loop. I hadn't tested my reverse method with enough characters *blush*. So at this stage I suggest you decide on a number of characters instead and use substring. I could adjust it to do a split based on 'sentences' (ie. look for fullstops, but even that may not be sufficient. Sorry for getting your hopes up, I'm disappointed too, thought I was on to a good solution. Hi Skarn, Thank you for the reply. It's okay. I will definitely think about using the character instead of substring. Thank you again for your help. :) Page 1 of 1 (11 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Sorry, I guess I'm not understanding. If your input phrase is "Represents text that should be kept confidential", what should be the end result?
No, I don't think there's anything as simple as what you're asking about, but this should work for getting the first 6 words of a string:
substring(field, 1, string-length(field) - string-length(substring-after(substring-after(substring-after(substring-after(substring-after(substring-after(field, " "), " "), " "), " "), " "), " ")))
Jimmy:No, I don't think there's anything as simple as what you're asking about, but this should work for getting the first 6 words of a string: substring(field, 1, string-length(field) - string-length(substring-after(substring-after(substring-after(substring-after(substring-after(substring-after(field, " "), " "), " "), " "), " "), " ")))
I don't think there is a simple way to make it dynamic. You could modify it to nest more substring-after(..., " ")s in there until you have 200. Why do you want to to get the first 200 words of a string anyway? Wouldn't the number of characters be a more valid measurement in most cases?
Jimmy:I don't think there is a simple way to make it dynamic. You could modify it to nest more substring-after(..., " ")s in there until you have 200. Why do you want to to get the first 200 words of a string anyway? Wouldn't the number of characters be a more valid measurement in most cases?
I can do this, using rules and no code.
Can you please confirm for me if the following is correct."User types in words, when they move to next field, any words past the #th word are deleted." where # is a number decided by you.
Then, if you cross my palm with gol...hehe kidding. Then I'll post an example template.
Part of the solution involves reversing the characters in a field, which I've done, but never had a use for until now. :-P
Skarn:I can do this, using rules and no code. Can you please confirm for me if the following is correct."User types in words, when they move to next field, any words past the #th word are deleted." where # is a number decided by you.Then, if you cross my palm with gol...hehe kidding. Then I'll post an example template.Part of the solution involves reversing the characters in a field, which I've done, but never had a use for until now. :-P
hi yyc, my reverse text doesn't work as well as I thought - it suffers from an issue (which isn't really a bad thing) where Infopath won't let rules change a field continuously in case it gets stuck in a loop. I hadn't tested my reverse method with enough characters *blush*. So at this stage I suggest you decide on a number of characters instead and use substring.
I could adjust it to do a split based on 'sentences' (ie. look for fullstops, but even that may not be sufficient. Sorry for getting your hopes up, I'm disappointed too, thought I was on to a good solution.
Skarn: hi yyc, my reverse text doesn't work as well as I thought - it suffers from an issue (which isn't really a bad thing) where Infopath won't let rules change a field continuously in case it gets stuck in a loop. I hadn't tested my reverse method with enough characters *blush*. So at this stage I suggest you decide on a number of characters instead and use substring. I could adjust it to do a split based on 'sentences' (ie. look for fullstops, but even that may not be sufficient. Sorry for getting your hopes up, I'm disappointed too, thought I was on to a good solution.
Hi Skarn, Thank you for the reply. It's okay. I will definitely think about using the character instead of substring. Thank you again for your help. :)