Assist an amateur.

agolangf · · 432 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello, I have what I hope is a quick question. I&#39;m using a small bit of code that receives a feed from an API of a list of items and then displays specific items I&#39;m interested in based on a few variables.</p> <p>My issue I believe is pretty simple. Say you have an item type that is &#34;Apple&#34;. Now it can be a plain &#34;Apple&#34;, or sometimes can be a &#34;Juice Apple&#34; or a &#34;Apple Mush&#34;, or even a &#34;Juicy Apple Mush&#34;. But &#34;Apple&#34; will always be present.</p> <p>My issue is that the only item type I am getting returned is the plain &#34;Apple&#34; and the possible derivatives as mentioned above do not show up. I&#39;ve found using a wildcard * does not work. Note I am a complete amateur and really not clear on much of what I&#39;m doing ! :D</p> <p>I&#39;m hoping there is something simple I&#39;m missing that I can change to allow my searches to not just return plain &#34;Apple&#34;, but anything that contains &#34;Apple&#34; along with instances of &#34;Apple&#34; with a modifier that comes before, after or in both positions around &#34;Apple&#34;.</p> <p>This is the code, in this case I am only getting &#34;Breach Leaguestone&#34;, but not examples that are modified with a word before or after &#34;Breach Leaguestone&#34;, only the plain exact match.</p> <pre><code>func processStash(stash *api.Stash) { re := regexp.MustCompile(&#34;^~b/o ([0-9\\.]+) ([^ ]+)$&#34;) for _, item := range stash.Items { matches := re.FindStringSubmatch(item.Note) if len(matches) &lt; 3 { continue } boQuantity := matches[1] boCurrency := matches[2] if item.League == &#34;Legacy&#34; &amp;&amp; item.Type == &#34;Breach Leaguestone&#34; &amp;&amp; item.ItemLevel &gt;= 69 { log.Printf(&#34;@%v Hi I would like to buy your %v listed for %v %v in %v stash tab %v&#34;, stash.LastCharacterName, item.Type, boQuantity, boCurrency, item.League, stash.Label) } } </code></pre> <p>This is the relevant API: <a href="https://github.com/ccbrown/poe-go/blob/master/api/item.go" rel="nofollow">https://github.com/ccbrown/poe-go/blob/master/api/item.go</a></p> <p>Thanks in advance for any help! I assume this is a downright simple fix, just beyond my grasp.</p> <hr/>**评论:**<br/><br/>the_jester: <pre><p>Your regex is very likely not doing what you think it is doing. Test it <a href="https://regex101.com/" rel="nofollow">over here</a>.</p></pre>donniederpo: <pre><blockquote> <pre><code> if item.League == &#34;Legacy&#34; &amp;&amp; item.Type == &#34;Breach Leaguestone&#34; &amp;&amp; item.ItemLevel &gt;= 69 { </code></pre> </blockquote> <p>item.Type == &#34;Breach Leaguestone&#34; is your problem here, that requires an exact match for item.Type. You will need to change that to be a lazier match type.</p></pre>Yojihito: <pre><p>Are you building your own poe.trade indexer to beat the 20 second delay on that plattform?</p> <p>Also they patched the leaguestone trick and banned people for it (but only 00,01% I guess).</p></pre>JamesTCoconuts: <pre><p>Trying to lol.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

432 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传